| | |
| | | |
| | | import javax.swing.JTextField; |
| | | import javax.swing.UIManager; |
| | | import javax.swing.UnsupportedLookAndFeelException; |
| | | |
| | | import java.awt.Color; |
| | | import java.nio.ByteBuffer; |
| | |
| | | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.jvnet.substance.SubstanceLookAndFeel; |
| | | import org.jvnet.substance.border.StandardBorderPainter; |
| | | import org.jvnet.substance.button.ClassicButtonShaper; |
| | | import org.jvnet.substance.painter.ClassicGradientPainter; |
| | | import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; |
| | | import org.jvnet.substance.theme.SubstanceLightAquaTheme; |
| | | import org.jvnet.substance.title.Glass3DTitlePainter; |
| | | import org.jvnet.substance.watermark.SubstanceMetalWallWatermark; |
| | | |
| | | |
| | | public class main_window { |
| | | public static final int CommDevType_MON = 0; |
| | |
| | | public static int LANG_TYPE_EN = 1; |
| | | |
| | | //public String mTitle = "MSP&SAM&SWM&Curr_V1.523_220424G"; |
| | | public String mTitle = "汇集模块调试工具_V1.523_220424G"; |
| | | public String mTitle = "汇集模块调试工具_V1.523_SYY"; |
| | | |
| | | public static int LANG_TYPE = LANG_TYPE_CN; |
| | | public static final boolean APP_FBS9600_MON_EN = true; |
| | |
| | | frmSerialport.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| | | frmSerialport.setLocationRelativeTo(null); |
| | | |
| | | Panel panel = new Panel(); |
| | | frmSerialport.getContentPane().add(panel, BorderLayout.NORTH); |
| | | JPanel panel = new JPanel(); |
| | | //frmSerialport.getContentPane().add(panel, BorderLayout.NORTH); |
| | | frmSerialport.getContentPane().add(panel, BorderLayout.WEST); |
| | | String comm_title = "通信地址 / 波特率"; |
| | | if(LANG_TYPE_EN == LANG_TYPE) { |
| | | comm_title = "Comm Addr / Bit Rate"; |
| | | } |
| | | panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); |
| | | panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
| | | |
| | | panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "连接信息", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | |
| | | tab_comm_type = new JTabbedPane(JTabbedPane.TOP); |
| | | panel.add(tab_comm_type); |
| | | // panel.add(tab_comm_type); |
| | | |
| | | JPanel panel_8 = new JPanel(); |
| | | tab_comm_type.addTab("RS485\u901A\u4FE1", null, panel_8, null); |
| | | panel_8.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u4E32\u53E3\u53F7 / \u6CE2\u7279\u7387", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | panel_8.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0)); |
| | | //tab_comm_type.addTab("RS485\u901A\u4FE1", null, panel_8, null); |
| | | panel.add(panel_8); |
| | | //串口号/波特率\u4E32\u53E3\u53F7 / \u6CE2\u7279\u7387 |
| | | panel_8.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u4E32\u53E3\u53F7", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | |
| | | //panel_8.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0)); |
| | | panel_8.setLayout(new GridLayout(2,1,150,10)); |
| | | |
| | | btn_renew_commport = new JButton("\u5237\u65B0"); |
| | | panel_8.add(btn_renew_commport); |
| | | btn_renew_commport.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/arrow_refresh.png"))); |
| | | //btn_renew_commport.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/arrow_refresh.png"))); |
| | | btn_renew_commport.setFont(new Font("宋体", Font.PLAIN, 12)); |
| | | btn_renew_commport.addActionListener(new ActionListener() { |
| | | public void actionPerformed(ActionEvent arg0) { |
| | |
| | | //cb_commport.setModel(new DefaultComboBoxModel<String>(new String[] {"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10", "COM11", "COM12"})); |
| | | CommSerialPort.searchCommPort(cb_commport); |
| | | |
| | | |
| | | cb_comm_bitrate = new JComboBox(); |
| | | cb_comm_bitrate.setModel(new DefaultComboBoxModel(new String[] {"2400", "4800", "9600", "19200", "38400", "57600", "115200"})); |
| | | cb_comm_bitrate.setSelectedIndex(2); |
| | | panel_8.add(cb_comm_bitrate); |
| | | //panel_8.add(cb_comm_bitrate); |
| | | |
| | | cb_dev_type = new JComboBox(); |
| | | cb_dev_type.setModel(new DefaultComboBoxModel(new String[] {"SAM", "MSP", "MSP_RF", "SWM(\u534E\u82AF\u5A01\u7279)"})); |
| | | panel_8.add(cb_dev_type); |
| | | //panel_8.add(cb_dev_type); |
| | | |
| | | label = new JLabel(""); |
| | | panel_8.add(label); |
| | | //panel_8.add(label); |
| | | |
| | | panel_3 = new JPanel(); |
| | | FlowLayout flowLayout = (FlowLayout) panel_3.getLayout(); |
| | | flowLayout.setVgap(0); |
| | | panel_3.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "IP\u5730\u5740 / \u7AEF\u53E3", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | tab_comm_type.addTab("\u4EE5\u592A\u7F51\u901A\u4FE1", null, panel_3, null); |
| | | //tab_comm_type.addTab("\u4EE5\u592A\u7F51\u901A\u4FE1", null, panel_3, null); |
| | | |
| | | cb_tcp_udp = new JComboBox(); |
| | | cb_tcp_udp.setEnabled(false); |
| | |
| | | if(LANG_TYPE_EN == LANG_TYPE) { |
| | | comm_title = "Comm Port"; |
| | | } |
| | | panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u5907\u5730\u5740", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u5907\u5730\u5740 / 波特率", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | panel.add(panel_1); |
| | | if(cb_commport.getItemCount() > 0) { |
| | | cb_commport.setSelectedIndex(0); |
| | |
| | | if(LANG_TYPE_EN == LANG_TYPE) { |
| | | comm_title = "Reflesh"; |
| | | } |
| | | panel_1.setLayout(new GridLayout(0, 1, 0, 0)); |
| | | panel_1.setLayout(new GridLayout(0, 1, 10, 10)); |
| | | |
| | | btnNewButton = new JButton("\u4E0A\u4E00\u4E2A"); |
| | | //panel_1.add(btnNewButton); |
| | |
| | | tf_target_addr.setHorizontalAlignment(SwingConstants.CENTER); |
| | | tf_target_addr.setFont(new Font("宋体", Font.PLAIN, 32)); |
| | | panel_1.add(tf_target_addr); |
| | | panel_1.add(cb_comm_bitrate); |
| | | |
| | | |
| | | tf_target_addr.addFocusListener(new FocusAdapter() { |
| | | @Override |
| | | public void focusLost(FocusEvent e) { |
| | |
| | | } |
| | | } |
| | | }); |
| | | panel_2.setLayout(new GridLayout(0, 2, 0, 0)); |
| | | panel_2.setLayout(new GridLayout(0, 1, 10, 10)); |
| | | panel_2.add(btn_connet); |
| | | |
| | | comm_title = "断开"; |
| | |
| | | } |
| | | panel_9.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u901A\u4FE1\u8BA1\u6570(TX/RX)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); |
| | | panel.add(panel_9); |
| | | panel_9.setLayout(new GridLayout(0, 1, 0, 0)); |
| | | panel_9.setLayout(new GridLayout(0, 1, 10, 10)); |
| | | |
| | | tf_txcnt = new JTextField(); |
| | | tf_txcnt.setFont(new Font("宋体", Font.PLAIN, 16)); |
| | |
| | | } |
| | | } |
| | | |
| | | /************ 设置软件调试软件样式 ***********************/ |
| | | try { |
| | | UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); |
| | | SubstanceLookAndFeel.setCurrentTheme(new SubstanceLightAquaTheme()); |
| | | SubstanceLookAndFeel.setCurrentButtonShaper(new ClassicButtonShaper()); |
| | | SubstanceLookAndFeel.setCurrentWatermark(new SubstanceMetalWallWatermark()); |
| | | SubstanceLookAndFeel.setCurrentBorderPainter(new StandardBorderPainter()); |
| | | SubstanceLookAndFeel.setCurrentGradientPainter(new ClassicGradientPainter()); |
| | | SubstanceLookAndFeel.setCurrentTitlePainter(new Glass3DTitlePainter()); |
| | | } catch (UnsupportedLookAndFeelException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | /************************************/ |
| | | |
| | | /**************************************************************************/ |
| | | mMainFormTimer = new Timer(200, new ActionListener() { |
| | | @Override |