获取模拟电压值(第三篇)
来源:互联网 发布:恐怖悬疑电影 知乎 编辑:程序博客网 时间:2024/05/16 05:16
//文件StringLinewrap2.java
package cn.ch.da;import java.awt.EventQueue;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.border.EmptyBorder;import javax.swing.JLabel;import javax.swing.border.TitledBorder;import javax.swing.JScrollPane;import javax.swing.JButton;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import javax.swing.UIManager;public class StringLinewrap2 extends JFrame { private static final long serialVersionUID = -6696744628977225050L;private JPanel contentPane; private JTextArea sourceTextArea; private JTextArea destinationTextArea; private JTextArea destinationTextArea2; private JTextArea destinationTextArea3; /** * Launch the application. */ public static void main(String[] args) { try { UIManager .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Throwable e) { e.printStackTrace(); } EventQueue.invokeLater(new Runnable() { public void run() { try { StringLinewrap2 frame = new StringLinewrap2(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public StringLinewrap2() { setTitle("MQ-3型酒精传感器浓度分析"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 475, 660); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel label = new JLabel( "<html>MQ-3型酒精传感器浓度分析,在下面的文本框中输入字符串段落,其中要包括(02)字段,然后单击“分行显示”按钮,程序将根据(02)字段进行分行。</html>"); label.setBorder(new TitledBorder(null, "说明", TitledBorder.LEADING, TitledBorder.TOP, null, null)); label.setBounds(10, 10, 439, 76); contentPane.add(label); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 84, 439, 98); contentPane.add(scrollPane); sourceTextArea = new JTextArea(); sourceTextArea.setLineWrap(true); scrollPane.setViewportView(sourceTextArea); JButton button = new JButton("分行显示"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { do_button_actionPerformed(e); } }); JButton button2 = new JButton("酒精传感器"); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { do_button_actionPerformed2(e); } }); JButton button3 = new JButton("浓度值"); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { do_button_actionPerformed3(e); } }); button.setBounds(60, 192, 101, 25); button2.setBounds(210, 192, 101, 25); button3.setBounds(340, 192, 101, 25); contentPane.add(button); contentPane.add(button2); contentPane.add(button3); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(10, 233, 439, 156); contentPane.add(scrollPane_1); destinationTextArea = new JTextArea(); scrollPane_1.setViewportView(destinationTextArea); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setBounds(10, 390, 439, 156); contentPane.add(scrollPane_2); destinationTextArea2 = new JTextArea(); scrollPane_2.setViewportView(destinationTextArea2); JScrollPane scrollPane_3 = new JScrollPane(); scrollPane_3.setBounds(10, 548, 439, 50); contentPane.add(scrollPane_3); destinationTextArea3 = new JTextArea(); scrollPane_3.setViewportView(destinationTextArea3); } protected void do_button_actionPerformed(ActionEvent e) { String sourceString = sourceTextArea.getText();// 获取用户输入字段 String[] lines = sourceString.split("02");// 根据“02字段”分割字符串为数组 StringBuilder sbuilder = new StringBuilder();// 创建字符串构建器 for (String line : lines) {// 遍历分割后的字符串数组 // 把每个数组元素的字符串与回车符相连并添加到字符串构建器中 sbuilder.append(line + "\n"); } // 把字符串添加到换行显示字符串的文本域中 destinationTextArea.setText(sbuilder.toString()); } protected void do_button_actionPerformed2(ActionEvent e){ String destinon2String = destinationTextArea.getText(); //String tou="02",wei="85"; String[] lines = destinon2String.split("85\\ "); StringBuilder sbuilder2 = new StringBuilder(); for (String line : lines) {// 遍历分割后的字符串数组 // 把每个数组元素的字符串与回车符相连并添加到字符串构建器中 sbuilder2.append(line.substring(0, 2) + " "); } // 把字符串添加到换行显示字符串的文本域中 destinationTextArea2.setText(sbuilder2.toString()); } protected void do_button_actionPerformed3(ActionEvent e){ String destinon2String = destinationTextArea2.getText(); String[] lines = destinon2String.split(" "); StringBuilder sbuilder2 = new StringBuilder(); for (String line : lines) { sbuilder2.append(line+ " "); } // 把字符串添加到换行显示字符串的文本域中 destinationTextArea3.setText("浓度为: "+sbuilder2.toString()); } }
0 0
- 获取模拟电压值(第三篇)
- 获取模拟电压值(第二篇)
- 获取模拟电压值(第一篇)
- 【Espruino】NO.07 获取电压值
- 关于CSR8670读取模拟口上的电压值
- 利用 DAC0832 输出模拟电压
- 电压
- 获取android手机电池的电压和温度;
- 模拟电子技术19 34------——共集电极 无电压放大能力 =电压跟随器
- STM32测量外部电池电压值时参考电压解决方法
- 模拟电路----电压跟随器与功率放大器(转)
- 模拟信号处理电路:有源滤波器和电压比较器
- 【Arduino官方教程】基础示例(六):读取模拟电压
- 模拟电路 参考电压的设计 和 蜂鸣器驱动电路
- Java 服务端 使用WebService 模拟客户端从第三个平台获取数据
- 模拟电子技术20 35------——共集电极 无电压放大能力 续 电流放大高 电压跟随器
- 模拟第三周题
- 关于电压校准值的问题
- IT招聘量超越房地产 聚焦未来三大热门领域
- jquery grid
- 让人爱不释手的13套精美 Web 应用程序图标素材
- MFC 里的 CFile 类的一个函数 CreateFile
- 大家好 新人报道
- 获取模拟电压值(第三篇)
- 对java值传递和引用传递的一些理解
- Iperf 源代码分析(二)
- 不安装oracle使用sqlplus工具
- ACdream1007 a+b
- 女人,百花千红你最美
- 睡眠
- 两代创业人 两条创业路
- 阿里巴巴2014产品经理实习生武汉站面试之回忆