/* * Auther : Radioboy627 */ package MaceWindu; import gnu.io.*; import java.awt.event.ItemEvent; import java.awt.event.KeyEvent; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Enumeration; import java.util.TooManyListenersException; import java.util.Properties; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class MaceWindu extends javax.swing.JFrame { SerialPort COM; OutputStream ComOut; InputStream ComInputStream; BufferedReader COMReader; Properties Configure; String PreviousPortname; String PortName; String TxString; String RecievedString; String ConvertedStr; String PreviousWriteText; String LookAndFeelString; String PathString; String Version = "1.3.6"; String LafStr; String WriteFormatStr; String AddRBoolStr; String AddNBoolStr; String ReadModeStr; String ReadFormatStr; String Fix8BitBoolStr; String FixCapitalLetterBoolStr; String AddFormatRepresentationBoolStr; String ModeSelectedStr; String SaveBaudRateIndexString; String SaveDataBitsIndexString; String SaveStopBitsIndexString; String SaveParityIndexString; String SaveFlowControlIndexString; byte[] buffer = new byte[1024]; byte[] ConvertedByte; byte[] RecievedDataBs; char ConvertedChar; char PressedKeyChar; int PressedKeyCode; int ConvertedInt; int RecievedData; int Recieve; int TxData; int UnsignedTxData; int BaudRate=0; int DataBits=8; int StopBits=1; int Parity=0; int HandShake=0; boolean ButtonState = false; boolean PressedKeyCheck = false; boolean Init = false; public MaceWindu() { //PathStringは,現在実行中のJarファイルorクラスパスを取得して格納されてる! //ちなみに,デバック時に保存させると,クラスパスにiniファイルが残っちゃうよ-wwww //まあ,問題ないっちゃ無いけどねwww //リリースするときは注意!! //ちなみに,Jarファイルの場所をgetPropertyでは取得させてるから //substringで,Jarファイルの名前のとこ消さないとダメね PathString = System.getProperty("java.class.path"); PathString = PathString.substring(0, PathString.lastIndexOf(File.separator)+1); //JOptionPane.showMessageDialog(rootPane, PathString); //アンチエイリアスを有効化させるやつ // でも,なんか効かないみたいwwww System.setProperty("awt.useSystemAAFontSettings","on"); System.setProperty("swing.aatext", "true"); Configure = new Properties(); initComponents(); ReadFormatSelectMenuButtonGroup.add(ReadStrSelectMenuButton); ReadFormatSelectMenuButtonGroup.add(ReadBinSelectMenuButton); ReadFormatSelectMenuButtonGroup.add(ReadOctSelectMenuButton); ReadFormatSelectMenuButtonGroup.add(ReadDecSelectMenuButton); ReadFormatSelectMenuButtonGroup.add(ReadHexSelectMenuButton); ReadModeSelectMenuButtonGroup.add(ReadSelectMenuButton); ReadModeSelectMenuButtonGroup.add(ReadLineSelectMenuButton); WriteFormatSelectMenuButtonGroup.add(WriteStrSelectMenuButton); WriteFormatSelectMenuButtonGroup.add(WriteBinSelectMenuButton); WriteFormatSelectMenuButtonGroup.add(WriteOctSelectMenuButton); WriteFormatSelectMenuButtonGroup.add(WriteDecSelectMenuButton); WriteFormatSelectMenuButtonGroup.add(WriteHexSelectMenuButton); WriteTriggerSelectMenuButtonGroup.add(PressReturnKeySelectMenuButton); WriteTriggerSelectMenuButtonGroup.add(PressAnyKeySelectMenuButton); ModeSelectMenuButtonGroup.add(SeparateModeSelectMenuButton); ModeSelectMenuButtonGroup.add(TerminalModeSelectMenuButton); ReadSelectMenuButton.setSelected(true); ReadStrSelectMenuButton.setSelected(true); WriteStrSelectMenuButton.setSelected(true); PressReturnKeySelectMenuButton.setSelected(true); SeparateModeSelectMenuButton.setSelected(true); AvailableComPort(); ReadListenerEnable(); WriteTriggerMenu.setVisible(false); AboutDialogVersionLabel.setText("Version : " + Version); try { FileLoad(); } catch (Exception e) { } Init = true; } private void WriteConsole(String str){ java.lang.System.out.println(str); } private void ChangeLookAndFeel(String LafString){ /* if (LafMetalSelectMenuButton.isSelected() == true){ LookAndFeelString = "javax.swing.plaf.metal.MetalLookAndFeel"; } if (LafMotifSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } if (LafWindowsSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } if (LafWindowsClassicSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"; } if (LafMacSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.mac.MacLookAndFeel"; } if (LafGTKSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } if (LafNimbusSelectMenuButton.isSelected() == true){ LookAndFeelString = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; } */ try { //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel(LafString); SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(LafDialog); SwingUtilities.updateComponentTreeUI(AboutDialog); } catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { WriteConsole("Some Expention While Change LookAndFeel"); //MsgLabel.setText("Some Expention While Change LookAndFeel"); } } //文字列(string)を整数(int)にする関数 //IntValueはエラーの時に返すやつ。だから,実行するときにエラーで返してほしいやつ指定する private int ConvertStr2Int(String Strvalue, int Intvalue){ try { return Integer.parseInt(Strvalue); } catch (NumberFormatException e) { return Intvalue; } } private byte [] toByte(int IntData){ byte[] ByteData = new byte[4]; ByteData[0] = (byte)(0x000000ff & IntData); ByteData[1] = (byte)(0x0000ff00 & IntData); ByteData[2] = (byte)(0x00ff0000 & IntData); ByteData[3] = (byte)(0xff000000 & IntData); return ByteData; } private void AvailableComPort(){ PortsComboBox.removeAllItems(); PortsComboBox.addItem("-Ports-"); CommPortIdentifier portID = null; Enumeration portEnum = CommPortIdentifier.getPortIdentifiers(); if (portEnum.hasMoreElements()){ while (portEnum.hasMoreElements()){ CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement(); PortsComboBox.addItem(currPortId.getName()); } PortsComboBox.setSelectedIndex(0); }else{ JOptionPane.showMessageDialog(rootPane, "There Is No Available COM Port"); } } private boolean CheckComboBoxIndex(){ boolean val = true; if (PortsComboBox.getSelectedIndex() == 0 || BaudRateComboBox.getSelectedIndex() == 0 || DataBitsComboBox.getSelectedIndex() == 0 || StopBitsComboBox.getSelectedIndex() == 0 || ParityComboBox.getSelectedIndex() == 0 || FlowControlComboBox.getSelectedIndex() == 0 ){ val = false; } return val; } private void OpenComPort(String port){ if (CheckComboBoxIndex() == true){ BaudRate = ConvertStr2Int(BaudRateComboBox.getSelectedItem().toString(), 0); DataBits = ConvertStr2Int(DataBitsComboBox.getSelectedItem().toString(), 0); AssignParity(); AssignStopBits(); AssignHandShake(); try { CommPortIdentifier comID = CommPortIdentifier.getPortIdentifier(port); CommPort commPort = comID.open("MaceWindu", 2000); //引数はstring アプリケーション名 int タイムアウト時間 らしい (アプリケーション名は何にしてもおk!!ww) COM = (SerialPort)commPort; COM.setSerialPortParams(BaudRate, DataBits, StopBits, Parity); //COM.setSerialPortParams(2400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); COM.setFlowControlMode(HandShake); MsgLabel.setText(PortName + " Opened Successfully"); WriteConsole(PortName + " Opened Successfully"); ComboBoxEnSelect(true); ReadListenerEnable(); ReadEnable(); WriteEnable(); } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException e) { MsgLabel.setText("Error : Failed to Open " + PortName); WriteConsole("Error : Failed to Open " + PortName); ComboBoxEnSelect(false); } } } private void CloseComPort(){ try { COM.close(); } catch(Exception e) { WriteConsole("Error : Failed To Close " + PreviousPortname); MsgLabel.setText("Error : Failed To Close " + PreviousPortname); } } private void ComboBoxEnSelect(boolean i){ if (i == true){ BaudRateComboBox.setEnabled(true); DataBitsComboBox.setEnabled(true); StopBitsComboBox.setEnabled(true); ParityComboBox.setEnabled(true); FlowControlComboBox.setEnabled(true); }else{ BaudRateComboBox.setEnabled(false); DataBitsComboBox.setEnabled(false); StopBitsComboBox.setEnabled(false); ParityComboBox.setEnabled(false); FlowControlComboBox.setEnabled(false); } } public void WriteEnable(){ try { ComOut = COM.getOutputStream(); } catch (Exception e) { MsgLabel.setText("Error : WriteEnable()"); WriteConsole("Error : WriteEnable()"); } } public void ReadEnable(){ try { COM.enableReceiveThreshold(1); ComInputStream = COM.getInputStream(); COMReader = new BufferedReader(new InputStreamReader(COM.getInputStream())); } catch (UnsupportedCommOperationException | IOException e) { MsgLabel.setText("Error : An Error Occured In ReadEnable()"); WriteConsole("Error : An Error Occured In ReadEnable()"); } } private void Read(){ try{ if (ReadStrSelectMenuButton.isSelected() == true){ /*while (COMReader.ready()){ try { RecievedData = COMReader.read(); ConvertedChar = (char) RecievedData; ConvertedStr = String.valueOf(ConvertedChar); RecievedDataTextArea.append(ConvertedStr); } catch (Exception e) { MsgLabel.setText("An Error Occured At Read()"); } }*/ try { RecievedData = ComInputStream.read(); ConvertedChar = (char) RecievedData; ConvertedStr = String.valueOf(ConvertedChar); RecievedDataTextArea.append(ConvertedStr); } catch (Exception e) { } RecievedDataTextArea.setCaretPosition(RecievedDataTextArea.getText().length()); }else{ //while (ComInputStream.read() != -1) { //なんかよう分からんけど, != -1 にすると2回送信しないと受信しくれないwww //だからとりあえず,whileは外してtry-catch で Exception掴んでる try { RecievedData = ComInputStream.read(); if (ReadBinSelectMenuButton.isSelected() == true){ ConvertedStr = Integer.toBinaryString(RecievedData); //8桁になるように0を先頭に追加してくコード if (Fix8BitSelectMenuCheckBox.isSelected() == true){ while (ConvertedStr.length() <= 7){ ConvertedStr = "0" + ConvertedStr; } } if (AddFormatRepresentationSelectMenuCheckBox.isSelected() == true){ ConvertedStr = "0b" + ConvertedStr; } RecievedDataTextArea.append(ConvertedStr + " "); } if (ReadOctSelectMenuButton.isSelected() == true){ ConvertedStr = Integer.toOctalString(RecievedData); if (AddFormatRepresentationSelectMenuCheckBox.isSelected() == true){ ConvertedStr = "0" + ConvertedStr; } RecievedDataTextArea.append(ConvertedStr + " "); } if (ReadDecSelectMenuButton.isSelected() == true){ RecievedDataTextArea.append(String.valueOf(RecievedData) + " "); } if (ReadHexSelectMenuButton.isSelected() == true){ ConvertedStr = Integer.toHexString(RecievedData); if (FixCapitalLetterSelectMenuCheckBox.isSelected() == true){ ConvertedStr = ConvertedStr.toUpperCase(); } //2桁になるように0を先頭に追加してくコード if (Fix8BitSelectMenuCheckBox.isSelected() == true){ while (ConvertedStr.length() == 1){ ConvertedStr = "0" + ConvertedStr; } } if (AddFormatRepresentationSelectMenuCheckBox.isSelected() == true){ ConvertedStr = "0x" + ConvertedStr; } RecievedDataTextArea.append(ConvertedStr + " "); } } catch (Exception e) { MsgLabel.setText("An Error Occured At Read()"); } RecievedDataTextArea.setCaretPosition(RecievedDataTextArea.getText().length()); //} } } catch (Exception e){ } } private void ReadLine(){ try { while(COMReader.ready()){ RecievedString = COMReader.readLine(); RecievedDataTextArea.append(RecievedString); RecievedDataTextArea.setCaretPosition(RecievedDataTextArea.getText().length()); //DataLabel.setText(RecievedString); //System.out.println(RecievedString); } } catch (IOException e) { MsgLabel.setText("Error : An Error Occured At ReadLine()"); WriteConsole("Error : An Error Occured At ReadLine()"); } //JOptionPane.showMessageDialog(rootPane, "受信成功!"); //MsgLabel.setText("Data Received Successfully!!"); } private void ReadListenerEnable(){ try { COM.addEventListener(new SerialPortlistener()); COM.notifyOnDataAvailable(true); COM.enableReceiveThreshold(1); } catch (TooManyListenersException e) { //WriteConsole("Error : TooManyListenersException"); //MsgLabel.setText("Error : TooManyListenersException"); } catch(UnsupportedCommOperationException e){ //WriteConsole("Error : Occured While ReadListenerEnable"); //MsgLabel.setText("Error : Occured While ReadListenerEnable"); } catch(Exception e){ //MsgLabel.setText("Error : An Error Occured in ReadListenerEnable()"); //WriteConsole("Error : An Error Occured in ReadListenerEnable()"); } } private void MessageOutPut(String string){ MsgLabel.setText(string); WriteConsole(string); } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { LafDialog = new javax.swing.JDialog(); jPanel3 = new javax.swing.JPanel(); LafComboBox = new javax.swing.JComboBox(); LafDialogCloseButton = new javax.swing.JButton(); LafDialogApplyButton = new javax.swing.JButton(); AboutDialog = new javax.swing.JDialog(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); AboutDialogVersionLabel = new javax.swing.JLabel(); AboutDialogOkButton = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); ReadModeSelectMenuButtonGroup = new javax.swing.ButtonGroup(); ReadFormatSelectMenuButtonGroup = new javax.swing.ButtonGroup(); WriteFormatSelectMenuButtonGroup = new javax.swing.ButtonGroup(); WriteTriggerSelectMenuButtonGroup = new javax.swing.ButtonGroup(); ChangeLookAndFeelMenuButtonGroup = new javax.swing.ButtonGroup(); ModeSelectMenuButtonGroup = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); RecievedDataTextArea = new javax.swing.JTextArea(); WriteButton = new javax.swing.JButton(); PortsComboBox = new javax.swing.JComboBox(); BaudRateComboBox = new javax.swing.JComboBox(); DataBitsComboBox = new javax.swing.JComboBox(); StopBitsComboBox = new javax.swing.JComboBox(); ParityComboBox = new javax.swing.JComboBox(); FlowControlComboBox = new javax.swing.JComboBox(); WriteTextField = new javax.swing.JTextField(); MsgLabel = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); FileMenu = new javax.swing.JMenu(); MaceWinduCloseMenuItem = new javax.swing.JMenuItem(); WritePreferenceMenu = new javax.swing.JMenu(); WriteTriggerMenu = new javax.swing.JMenu(); PressReturnKeySelectMenuButton = new javax.swing.JRadioButtonMenuItem(); PressAnyKeySelectMenuButton = new javax.swing.JRadioButtonMenuItem(); jMenu2 = new javax.swing.JMenu(); WriteStrSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); WriteBinSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); WriteOctSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); WriteDecSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); WriteHexSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); AddRSelectMenuCheckBox = new javax.swing.JCheckBoxMenuItem(); AddNSelectMenuCheckBox = new javax.swing.JCheckBoxMenuItem(); ReadPreferenceMenu = new javax.swing.JMenu(); jMenu3 = new javax.swing.JMenu(); ReadSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadLineSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadFormatSelectMenu = new javax.swing.JMenu(); ReadStrSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadBinSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadOctSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadDecSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ReadHexSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); Fix8BitSelectMenuCheckBox = new javax.swing.JCheckBoxMenuItem(); FixCapitalLetterSelectMenuCheckBox = new javax.swing.JCheckBoxMenuItem(); AddFormatRepresentationSelectMenuCheckBox = new javax.swing.JCheckBoxMenuItem(); ModeSelectMenu = new javax.swing.JMenu(); SeparateModeSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); TerminalModeSelectMenuButton = new javax.swing.JRadioButtonMenuItem(); ToolsMenu = new javax.swing.JMenu(); RefreshPortsListMenuItem = new javax.swing.JMenuItem(); ClearRecievedDataMenuItem = new javax.swing.JMenuItem(); LafMenuItem = new javax.swing.JMenuItem(); AboutMenuItem = new javax.swing.JMenuItem(); LafDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); LafDialog.setTitle("Look And Feel"); LafDialog.setAlwaysOnTop(true); LafDialog.setBounds(new java.awt.Rectangle(0, 0, 0, 0)); LafDialog.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); LafDialog.setModal(true); LafDialog.setResizable(false); LafComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { LafComboBoxItemStateChanged(evt); } }); LafDialogCloseButton.setText("Close"); LafDialogCloseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LafDialogCloseButtonActionPerformed(evt); } }); LafDialogApplyButton.setText("Apply"); LafDialogApplyButton.setEnabled(false); LafDialogApplyButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { LafDialogApplyButtonMouseClicked(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(LafComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addGap(0, 340, Short.MAX_VALUE) .addComponent(LafDialogApplyButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(LafDialogCloseButton))) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(LafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(LafDialogCloseButton) .addComponent(LafDialogApplyButton)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout LafDialogLayout = new javax.swing.GroupLayout(LafDialog.getContentPane()); LafDialog.getContentPane().setLayout(LafDialogLayout); LafDialogLayout.setHorizontalGroup( LafDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); LafDialogLayout.setVerticalGroup( LafDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); AboutDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); AboutDialog.setTitle("About"); AboutDialog.setModal(true); jLabel1.setFont(new java.awt.Font("TakaoPGothic", 0, 24)); // NOI18N jLabel1.setText("MaceWindu"); AboutDialogVersionLabel.setText("In Code"); AboutDialogOkButton.setText("OK"); AboutDialogOkButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AboutDialogOkButtonActionPerformed(evt); } }); jLabel3.setText("Auther : Simon Kojima"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(127, 127, 127) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(70, 70, 70) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(AboutDialogVersionLabel)))) .addContainerGap(130, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(AboutDialogOkButton) .addGap(175, 175, 175)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36) .addComponent(AboutDialogVersionLabel) .addGap(18, 18, 18) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE) .addComponent(AboutDialogOkButton) .addContainerGap()) ); javax.swing.GroupLayout AboutDialogLayout = new javax.swing.GroupLayout(AboutDialog.getContentPane()); AboutDialog.getContentPane().setLayout(AboutDialogLayout); AboutDialogLayout.setHorizontalGroup( AboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); AboutDialogLayout.setVerticalGroup( AboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MaceWindu"); setResizable(false); jPanel1.setMaximumSize(new java.awt.Dimension(50000, 50000)); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); RecievedDataTextArea.setEditable(false); RecievedDataTextArea.setColumns(20); RecievedDataTextArea.setLineWrap(true); RecievedDataTextArea.setRows(5); RecievedDataTextArea.setWrapStyleWord(true); RecievedDataTextArea.setAutoscrolls(false); RecievedDataTextArea.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); RecievedDataTextArea.setFocusable(false); RecievedDataTextArea.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { RecievedDataTextAreaKeyTyped(evt); } }); jScrollPane1.setViewportView(RecievedDataTextArea); WriteButton.setText("Write"); WriteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteButtonActionPerformed(evt); } }); PortsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Ports-" })); PortsComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { PortsComboBoxItemStateChanged(evt); } }); BaudRateComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Baud Rate-", "300", "600", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200" })); BaudRateComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { BaudRateComboBoxItemStateChanged(evt); } }); DataBitsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Data Bits-", "5", "6", "7", "8" })); DataBitsComboBox.setSelectedIndex(4); DataBitsComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { DataBitsComboBoxItemStateChanged(evt); } }); StopBitsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Stop Bits-", "1", "1.5", "2" })); StopBitsComboBox.setSelectedIndex(1); StopBitsComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { StopBitsComboBoxItemStateChanged(evt); } }); ParityComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Parity-", "Even", "Mark", "None", "Odd", "Space" })); ParityComboBox.setSelectedIndex(3); ParityComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { ParityComboBoxItemStateChanged(evt); } }); FlowControlComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-Flow Control-", "None", "RTSCTS_IN", "TRSCTS_OUT", "XOnXOff_IN", "XOnXOff_OUT" })); FlowControlComboBox.setSelectedIndex(1); FlowControlComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { FlowControlComboBoxItemStateChanged(evt); } }); WriteTextField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { WriteTextFieldKeyReleased(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { WriteTextFieldKeyTyped(evt); } }); MsgLabel.setText("MsgLabel"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(WriteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 763, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(WriteButton)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(PortsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(BaudRateComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(DataBitsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(StopBitsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ParityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(FlowControlComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(MsgLabel))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(PortsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(BaudRateComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(DataBitsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(StopBitsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ParityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(FlowControlComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(WriteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(WriteButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(MsgLabel) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); FileMenu.setText("File"); MaceWinduCloseMenuItem.setText("Exit"); MaceWinduCloseMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MaceWinduCloseMenuItemActionPerformed(evt); } }); FileMenu.add(MaceWinduCloseMenuItem); jMenuBar1.add(FileMenu); WritePreferenceMenu.setText("Write Preference"); WriteTriggerMenu.setText("Write Trigger"); PressReturnKeySelectMenuButton.setText("Press Return Key"); WriteTriggerMenu.add(PressReturnKeySelectMenuButton); PressAnyKeySelectMenuButton.setText("Press Any Key"); WriteTriggerMenu.add(PressAnyKeySelectMenuButton); WritePreferenceMenu.add(WriteTriggerMenu); jMenu2.setText("Write Format"); WriteStrSelectMenuButton.setText("String"); WriteStrSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteStrSelectMenuButtonActionPerformed(evt); } }); jMenu2.add(WriteStrSelectMenuButton); WriteBinSelectMenuButton.setText("Binary"); WriteBinSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteBinSelectMenuButtonActionPerformed(evt); } }); jMenu2.add(WriteBinSelectMenuButton); WriteOctSelectMenuButton.setText("Octal"); WriteOctSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteOctSelectMenuButtonActionPerformed(evt); } }); jMenu2.add(WriteOctSelectMenuButton); WriteDecSelectMenuButton.setText("Decimal"); WriteDecSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteDecSelectMenuButtonActionPerformed(evt); } }); jMenu2.add(WriteDecSelectMenuButton); WriteHexSelectMenuButton.setText("Hexadecimal"); WriteHexSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WriteHexSelectMenuButtonActionPerformed(evt); } }); jMenu2.add(WriteHexSelectMenuButton); WritePreferenceMenu.add(jMenu2); AddRSelectMenuCheckBox.setText("Add \\r"); AddRSelectMenuCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddRSelectMenuCheckBoxActionPerformed(evt); } }); WritePreferenceMenu.add(AddRSelectMenuCheckBox); AddNSelectMenuCheckBox.setText("Add \\n"); AddNSelectMenuCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddNSelectMenuCheckBoxActionPerformed(evt); } }); WritePreferenceMenu.add(AddNSelectMenuCheckBox); jMenuBar1.add(WritePreferenceMenu); ReadPreferenceMenu.setText("Read Preference"); jMenu3.setText("Read Mode"); ReadSelectMenuButton.setText("Read"); ReadSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadSelectMenuButtonActionPerformed(evt); } }); jMenu3.add(ReadSelectMenuButton); ReadLineSelectMenuButton.setText("ReadLine"); ReadLineSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadLineSelectMenuButtonActionPerformed(evt); } }); jMenu3.add(ReadLineSelectMenuButton); ReadPreferenceMenu.add(jMenu3); ReadFormatSelectMenu.setText("Read Format"); ReadStrSelectMenuButton.setText("String"); ReadStrSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadStrSelectMenuButtonActionPerformed(evt); } }); ReadFormatSelectMenu.add(ReadStrSelectMenuButton); ReadBinSelectMenuButton.setText("Binary"); ReadBinSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadBinSelectMenuButtonActionPerformed(evt); } }); ReadFormatSelectMenu.add(ReadBinSelectMenuButton); ReadOctSelectMenuButton.setText("Octal"); ReadOctSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadOctSelectMenuButtonActionPerformed(evt); } }); ReadFormatSelectMenu.add(ReadOctSelectMenuButton); ReadDecSelectMenuButton.setText("Decimal"); ReadDecSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadDecSelectMenuButtonActionPerformed(evt); } }); ReadFormatSelectMenu.add(ReadDecSelectMenuButton); ReadHexSelectMenuButton.setText("Hexadecimal"); ReadHexSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadHexSelectMenuButtonActionPerformed(evt); } }); ReadFormatSelectMenu.add(ReadHexSelectMenuButton); ReadPreferenceMenu.add(ReadFormatSelectMenu); Fix8BitSelectMenuCheckBox.setText("Fix to 8bit"); Fix8BitSelectMenuCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Fix8BitSelectMenuCheckBoxActionPerformed(evt); } }); ReadPreferenceMenu.add(Fix8BitSelectMenuCheckBox); FixCapitalLetterSelectMenuCheckBox.setText("Fix to Capital Letter"); FixCapitalLetterSelectMenuCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { FixCapitalLetterSelectMenuCheckBoxActionPerformed(evt); } }); ReadPreferenceMenu.add(FixCapitalLetterSelectMenuCheckBox); AddFormatRepresentationSelectMenuCheckBox.setText("Add Format Representation"); AddFormatRepresentationSelectMenuCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddFormatRepresentationSelectMenuCheckBoxActionPerformed(evt); } }); ReadPreferenceMenu.add(AddFormatRepresentationSelectMenuCheckBox); jMenuBar1.add(ReadPreferenceMenu); ModeSelectMenu.setText("Mode"); SeparateModeSelectMenuButton.setText("Separate Mode"); SeparateModeSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SeparateModeSelectMenuButtonActionPerformed(evt); } }); ModeSelectMenu.add(SeparateModeSelectMenuButton); TerminalModeSelectMenuButton.setText("Terminal Mode"); TerminalModeSelectMenuButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TerminalModeSelectMenuButtonActionPerformed(evt); } }); ModeSelectMenu.add(TerminalModeSelectMenuButton); jMenuBar1.add(ModeSelectMenu); ToolsMenu.setText("Tools"); RefreshPortsListMenuItem.setText("Refresh Ports List"); RefreshPortsListMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RefreshPortsListMenuItemActionPerformed(evt); } }); ToolsMenu.add(RefreshPortsListMenuItem); ClearRecievedDataMenuItem.setText("Clear Recieved Data"); ClearRecievedDataMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearRecievedDataMenuItemActionPerformed(evt); } }); ToolsMenu.add(ClearRecievedDataMenuItem); LafMenuItem.setText("Look And Feel"); LafMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LafMenuItemActionPerformed(evt); } }); ToolsMenu.add(LafMenuItem); AboutMenuItem.setText("About"); AboutMenuItem.setToolTipText(""); AboutMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AboutMenuItemActionPerformed(evt); } }); ToolsMenu.add(AboutMenuItem); jMenuBar1.add(ToolsMenu); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); pack(); setLocationRelativeTo(null); }// //GEN-END:initComponents private void WriteStr(String StrSend){ if (BaudRateComboBox.getSelectedIndex() == 0){ MsgLabel.setText("Error : Please Select Baud Rate"); WriteConsole("Error : Please Select Baud Rate"); } try { byte[] data = StrSend.getBytes(); ComOut.write(data); //JOptionPane.showMessageDialog(rootPane, "送信完了!!!"); } catch (Exception e) { MsgLabel.setText("Error : An Error Occured At WriteStr()"); WriteConsole("Error : An Error Occured At WriteStr()"); } } private void Write(int IntSend){ if (BaudRateComboBox.getSelectedIndex() == 0){ MsgLabel.setText("Error : Please Select Baud Rate"); WriteConsole("Error : Please Select Baud Rate"); } try { ComOut.write(IntSend); //ComOut.write(buffer, WIDTH, IntSend); } catch (Exception e) { MsgLabel.setText("Error : An Error Occured At Write()"); WriteConsole("Error : An Error Occured At Write()"); } } private void PortsComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_PortsComboBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED){ PortName = PortsComboBox.getSelectedItem().toString(); if (PortsComboBox.getSelectedIndex() >= 1){ ComboBoxEnSelect(true); //MsgLabel.setVisible(true); CloseComPort(); OpenComPort(PortName); PreviousPortname = PortsComboBox.getSelectedItem().toString(); }else{ ComboBoxEnSelect(false); MsgLabel.setText("Please Select SerialPort"); WriteConsole("Please Select SerialPort"); } } }//GEN-LAST:event_PortsComboBoxItemStateChanged private void BaudRateComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_BaudRateComboBoxItemStateChanged if (Init == true){ CloseComPort(); if (evt.getStateChange() == ItemEvent.SELECTED){ if (BaudRateComboBox.getSelectedIndex() >= 1){ BaudRate = ConvertStr2Int(BaudRateComboBox.getSelectedItem().toString(), 0); if (BaudRate != 0){ try { //MessageboxShow(PortsComboBox.getSelectedItem().toString()); OpenComPort(PortsComboBox.getSelectedItem().toString()); //MsgLabel.setText(null); } catch (Exception e) { MsgLabel.setText("Error : Failed to Change BaudRate"); WriteConsole("Error : Failed to Change BaudRate"); } }else{ MsgLabel.setText("Error : Unknown BaudRate Value"); WriteConsole("Error : Unknown BaudRate Value"); } }else{ //MsgLabel.setText(null); } FileSave(); } } }//GEN-LAST:event_BaudRateComboBoxItemStateChanged private void DataBitsComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_DataBitsComboBoxItemStateChanged if (Init == true){ CloseComPort(); if (evt.getStateChange() == ItemEvent.SELECTED){ if (DataBitsComboBox.getSelectedIndex() >= 1){ DataBits = ConvertStr2Int(DataBitsComboBox.getSelectedItem().toString(), 0); if (DataBits != 0){ try { OpenComPort(PortName); //MsgLabel.setText(null); } catch (Exception e) { MsgLabel.setText("Error : Failed to Change Data Bits"); WriteConsole("Error : Failed to Change Data Bits"); } } }else{ //MsgLabel.setText(null); } FileSave(); } } }//GEN-LAST:event_DataBitsComboBoxItemStateChanged private void AssignStopBits(){ if (StopBitsComboBox.getSelectedIndex() == 1){ StopBits = 1; } else if (StopBitsComboBox.getSelectedIndex() == 2){ StopBits = 3; } else if (StopBitsComboBox.getSelectedIndex() == 3){ StopBits = 2; } } private void StopBitsComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_StopBitsComboBoxItemStateChanged if (Init == true){ CloseComPort(); if (evt.getStateChange() == ItemEvent.SELECTED){ if (StopBitsComboBox.getSelectedIndex() >= 1){ AssignStopBits(); try { OpenComPort(PortName); //MsgLabel.setText(null); } catch (Exception e) { MsgLabel.setText("Error : Failed to Change Stop Bits"); WriteConsole("Error : Failed to Change Stop Bits"); } }else{ //MsgLabel.setText(null); } FileSave(); } } }//GEN-LAST:event_StopBitsComboBoxItemStateChanged private void AssignParity(){ if (ParityComboBox.getSelectedIndex() == 1){ Parity = 2; } if (ParityComboBox.getSelectedIndex() == 2){ Parity = 3; } if (ParityComboBox.getSelectedIndex() == 3){ Parity = 0; } if (ParityComboBox.getSelectedIndex() == 4){ Parity =1; } if (ParityComboBox.getSelectedIndex() == 5){ Parity = 4; } } private void ParityComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ParityComboBoxItemStateChanged if (Init == true){ CloseComPort(); if (evt.getStateChange() == ItemEvent.SELECTED){ if (ParityComboBox.getSelectedIndex() >= 1){ AssignParity(); try { OpenComPort(PortName); //MsgLabel.setText(null); } catch (Exception e) { MsgLabel.setText("Error : Failed to Change Parity"); WriteConsole("Error : Failed to Change Parity"); } }else{ //MsgLabel.setText(null); } FileSave(); } } }//GEN-LAST:event_ParityComboBoxItemStateChanged private void AssignHandShake(){ if (FlowControlComboBox.getSelectedIndex() == 1){ HandShake = 0; } if (FlowControlComboBox.getSelectedIndex() == 2){ HandShake = 1; } if (FlowControlComboBox.getSelectedIndex() == 3){ HandShake = 2; } if (FlowControlComboBox.getSelectedIndex() == 4){ HandShake = 4; } if (FlowControlComboBox.getSelectedIndex() == 5){ HandShake = 8; } } private void FlowControlComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_FlowControlComboBoxItemStateChanged if (Init == true){ CloseComPort(); if (evt.getStateChange() == ItemEvent.SELECTED){ if (FlowControlComboBox.getSelectedIndex() >= 1){ AssignHandShake(); try { OpenComPort(PortName); //MsgLabel.setText(null); } catch (Exception e) { MsgLabel.setText("Error : Failed to Change HandShake"); WriteConsole("Error : Failed to Change HandShake"); } }else{ //MsgLabel.setText(null); } FileSave(); } } }//GEN-LAST:event_FlowControlComboBoxItemStateChanged private void WriteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteButtonActionPerformed if (WriteStrSelectMenuButton.isSelected() == true){ TxString = (WriteTextField.getText()); if (AddNSelectMenuCheckBox.isSelected() == true){ TxString += ("\n"); } if (AddRSelectMenuCheckBox.isSelected() == true){ TxString += ("\r"); } WriteStr(TxString); } if (WriteBinSelectMenuButton.isSelected() == true){ TxData = Integer.parseInt(WriteTextField.getText(), 2); Write(TxData); } if (WriteOctSelectMenuButton.isSelected() == true){ TxData = Integer.parseInt(WriteTextField.getText(), 8); Write(TxData); } if (WriteDecSelectMenuButton.isSelected() == true){ TxData = Integer.parseInt(WriteTextField.getText(), 10); Write(TxData); } if (WriteHexSelectMenuButton.isSelected() == true){ TxData = Integer.parseInt(WriteTextField.getText(), 16); Write(TxData); } }//GEN-LAST:event_WriteButtonActionPerformed private void WriteTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_WriteTextFieldKeyReleased if (PressAnyKeySelectMenuButton.isSelected() == true){ TxString = (WriteTextField.getText()); if (AddNSelectMenuCheckBox.isSelected() == true){ TxString += ("\n"); } if (AddRSelectMenuCheckBox.isSelected() == true){ TxString += ("\r"); } WriteStr(TxString); WriteTextField.setText(null); } if ((WriteDecSelectMenuButton.isSelected() == true) && (PressedKeyCheck == true) && (WriteTextField.getText() != null)){ ConvertedInt = Integer.valueOf(WriteTextField.getText()); if (ConvertedInt > 255){ JOptionPane.showMessageDialog(rootPane, "Can't Transmitt Over a Byte"); WriteConsole("Error : Can't Transmitt Over a Byte"); } } if ((WriteOctSelectMenuButton.isSelected() == true) && (PressedKeyCheck == true) && (WriteTextField.getText() != null)){ ConvertedInt = Integer.parseInt(WriteTextField.getText(), 8); if (ConvertedInt > 255){ JOptionPane.showMessageDialog(rootPane, "Can't Transmitt Over a Byte"); WriteConsole("Error : Can't Transmitt Over a Byte"); } } if (WriteHexSelectMenuButton.isSelected() == true){ WriteTextField.setText(WriteTextField.getText().toUpperCase()); } }//GEN-LAST:event_WriteTextFieldKeyReleased private void WriteTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_WriteTextFieldKeyTyped //ここ超大切!! //2進数を送信する設定にされてる時とかに //テキストフィールドに入力される文字列に制限をかけるプログラムだけど //キーが押された時に,8文字だったら入力された文字列の先頭から8文字目までを入力してる //これをもしも,9文字押された時にしちゃうと,キーが押された時点では8文字だから,9文字入力されちゃうww //かと言って,キーが離された時にしちゃうと,キーを長押ししたりした時に面倒だからダメ! //だから,8文字入った時点で8文字に制限してあげる //16進数でも同じね! //8進数と10進数では文字列をint型に変換して,255よりも大きかったらエラー吐かせるww //でも,キーが離された時にしないと1桁多くなっちゃうからねー //キーコード //0=48 //1=49 //2=50 //3=51 //4=52 //5=53 //6=54 //7=55 //8=56 //9=57 //A=65 //B=66 //C=67 //D=68 //E=69 //F=70 //a=97 //b=98 //c=99 //d=100 //e=101 //f=102 if (evt.getKeyChar() == KeyEvent.VK_ESCAPE){ WriteTextField.setText(null); } if (PressReturnKeySelectMenuButton.isSelected() == true){ if (evt.getKeyChar()== KeyEvent.VK_ENTER){ WriteButton.doClick(); } } //ここだけに書いとくと,一回押しただけじゃ何か送信されないみたいwww //だからキーがリリースされた時にも同じことさせてる if (PressAnyKeySelectMenuButton.isSelected() == true){ TxString = (WriteTextField.getText()); if (AddNSelectMenuCheckBox.isSelected() == true){ TxString += ("\n"); } if (AddRSelectMenuCheckBox.isSelected() == true){ TxString += ("\r"); } WriteStr(TxString); WriteTextField.setText(null); } if (WriteBinSelectMenuButton.isSelected() == true){ if ((evt.getKeyChar() == '0') || (evt.getKeyChar() == '1')){ if (WriteTextField.getText().length() >= 8){ WriteTextField.setText(WriteTextField.getText().substring(0, 7)); } }else{ evt.consume(); } } if (WriteDecSelectMenuButton.isSelected() == true){ PressedKeyChar = evt.getKeyChar(); if ((PressedKeyChar >= 48) && (PressedKeyChar <= 57)){//0〜9だったら PressedKeyCheck = true; if (WriteTextField.getText().length() >= 3){ WriteTextField.setText(WriteTextField.getText().substring(0, 2)); } }else{ evt.consume(); PressedKeyCheck = false; } } if (WriteOctSelectMenuButton.isSelected() == true){ PressedKeyChar = evt.getKeyChar(); if ((PressedKeyChar >= 48) && (PressedKeyChar <= 56)){ PressedKeyCheck = true; if (WriteTextField.getText().length() >= 3){ WriteTextField.setText(WriteTextField.getText().substring(0, 2)); } }else{ evt.consume(); PressedKeyCheck = false; } } if (WriteHexSelectMenuButton.isSelected() == true){ PressedKeyChar = evt.getKeyChar(); if (((PressedKeyChar >= 48) && (PressedKeyChar <= 57)) || ((PressedKeyChar >= 65) && (PressedKeyChar <= 70)) || ((PressedKeyChar >= 97) && (PressedKeyChar <= 102))){ WriteTextField.setText(WriteTextField.getText().toUpperCase()); PressedKeyCheck = true; if (WriteTextField.getText().length() >= 2){ WriteTextField.setText(WriteTextField.getText().substring(0, 1)); } }else{ evt.consume(); PressedKeyCheck = false; } } }//GEN-LAST:event_WriteTextFieldKeyTyped private void AvailableLaf(){ LafComboBox.removeAllItems(); UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); String[] ret = new String[info.length]; for(int i = 0; i < info.length; i++) { LafComboBox.addItem(info[i].getClassName()); } //JOptionPane.showMessageDialog(rootPane, UIManager.getLookAndFeel().getClass()); //JOptionPane.showMessageDialog(rootPane, String.valueOf(UIManager.getLookAndFeel().getClass()).substring(6,(String.valueOf(UIManager.getLookAndFeel().getClass()).length()))); LafComboBox.setSelectedItem(String.valueOf(UIManager.getLookAndFeel().getClass()).substring(6,String.valueOf(UIManager.getLookAndFeel().getClass()).length())); LafDialogApplyButton.setEnabled(false); } private String GetLookAndFeelStr(){ String string; String LafClassName; LafClassName = UIManager.getLookAndFeel().getClass().toString(); string = LafClassName.substring(6); return string; } private String GetWriteFormatStr(){ String string = null; if (WriteStrSelectMenuButton.isSelected() == true){ string = "String"; }else if (WriteBinSelectMenuButton.isSelected() == true){ string = "Bin"; }else if (WriteOctSelectMenuButton.isSelected() == true){ string = "Oct"; }else if (WriteDecSelectMenuButton.isSelected() == true){ string = "Dec"; }else if (WriteHexSelectMenuButton.isSelected() == true){ string = "Hex"; } return string; } private String GetAddRBoolStr(){ String string; if (AddRSelectMenuCheckBox.isSelected() == true){ string = "True"; }else{ string = "False"; } return string; } private String GetAddNBoolStr(){ String string; if (AddNSelectMenuCheckBox.isSelected() == true){ string = "True"; }else{ string = "False"; } return string; } private String GetReadModeStr(){ String string = null; if (ReadSelectMenuButton.isSelected() == true){ string = "Read"; }else if (ReadLineSelectMenuButton.isSelected() == true){ string = "ReadLine"; } return string; } private String GetReadFormatStr(){ String string = null; if (ReadStrSelectMenuButton.isSelected() == true){ string = "String"; }else if (ReadBinSelectMenuButton.isSelected() == true){ string = "Bin"; }else if (ReadOctSelectMenuButton.isSelected() == true){ string = "Oct"; }else if (ReadDecSelectMenuButton.isSelected() == true){ string = "Dec"; }else if (ReadHexSelectMenuButton.isSelected() == true){ string = "Hex"; } return string; } private String GetFix8BitBootStr(){ String string; if (Fix8BitSelectMenuCheckBox.isSelected() == true){ string = "True"; }else{ string = "False"; } return string; } private String GetFixCapitalLetterBoolStr(){ String string; if (FixCapitalLetterSelectMenuCheckBox.isSelected() == true){ string = "True"; }else{ string = "False"; } return string; } private String GetAddFormatRepresentationBoolStr(){ String string; if (AddFormatRepresentationSelectMenuCheckBox.isSelected() == true){ string = "True"; }else{ string = "False"; } return string; } private String GetModeSelectedStr(){ String string = null; if (SeparateModeSelectMenuButton.isSelected() == true){ string = "Separate"; }else if (TerminalModeSelectMenuButton.isSelected() == true){ string = "Terminal"; } return string; } private String GetSaveBaudRateIndexStr(){ String string; string = String.valueOf(BaudRateComboBox.getSelectedIndex()); return string; } private String GetSaveDataBitsIndexStr(){ String string; string = String.valueOf(DataBitsComboBox.getSelectedIndex()); return string; } private String GetSaveStopBitsIndexStr(){ String string; string = String.valueOf(StopBitsComboBox.getSelectedIndex()); return string; } private String GetSaveParityIndexStr(){ String string; string = String.valueOf(ParityComboBox.getSelectedIndex()); return string; } private String GetSaveFlowControlIndexStr(){ String string; string = String.valueOf(FlowControlComboBox.getSelectedIndex()); return string; } private void FileSave(){ SaveBaudRateIndexString = GetSaveBaudRateIndexStr(); SaveDataBitsIndexString = GetSaveDataBitsIndexStr(); SaveStopBitsIndexString = GetSaveStopBitsIndexStr(); SaveParityIndexString = GetSaveParityIndexStr(); SaveFlowControlIndexString = GetSaveFlowControlIndexStr(); LafStr = GetLookAndFeelStr(); WriteFormatStr = GetWriteFormatStr(); AddRBoolStr = GetAddRBoolStr(); AddNBoolStr = GetAddNBoolStr(); ReadModeStr = GetReadModeStr(); ReadFormatStr = GetReadFormatStr(); Fix8BitBoolStr = GetFix8BitBootStr(); FixCapitalLetterBoolStr = GetFixCapitalLetterBoolStr(); AddFormatRepresentationBoolStr = GetAddFormatRepresentationBoolStr(); ModeSelectedStr = GetModeSelectedStr(); Configure.setProperty("BaudRate", SaveBaudRateIndexString); Configure.setProperty("DataBits", SaveDataBitsIndexString); Configure.setProperty("StopBits", SaveStopBitsIndexString); Configure.setProperty("Parity", SaveParityIndexString); Configure.setProperty("FlowControl", SaveFlowControlIndexString); Configure.setProperty("LookAndFeel", LafStr); Configure.setProperty("WriteFormat", WriteFormatStr); Configure.setProperty("AddR", AddRBoolStr); Configure.setProperty("AddN", AddNBoolStr); Configure.setProperty("ReadMode", ReadModeStr); Configure.setProperty("ReadFormat", ReadFormatStr); Configure.setProperty("Fix8Bit", Fix8BitBoolStr); Configure.setProperty("FixCapitalLetter", FixCapitalLetterBoolStr); Configure.setProperty("AddFormatRepresentation", AddFormatRepresentationBoolStr); Configure.setProperty("ModeSelected", ModeSelectedStr); try { Configure.store(new FileOutputStream(PathString + "MaceWindu.ini"), null); } catch (Exception e) { } } private void FileLoad() throws IOException{ try { Configure.load(new FileInputStream(PathString + "MaceWindu.ini")); } catch (IOException e) { MsgLabel.setText(".ini File Not Found"); WriteConsole(".ini File Not Found"); } BaudRateComboBox.setSelectedIndex(Integer.valueOf(Configure.getProperty("BaudRate"))); DataBitsComboBox.setSelectedIndex(Integer.valueOf(Configure.getProperty("DataBits"))); StopBitsComboBox.setSelectedIndex(Integer.valueOf(Configure.getProperty("StopBits"))); ParityComboBox.setSelectedIndex(Integer.valueOf(Configure.getProperty("Parity"))); FlowControlComboBox.setSelectedIndex(Integer.valueOf(Configure.getProperty("FlowControl"))); //MessageboxShow(String.valueOf(Integer.valueOf(Configure.getProperty("FlowControl")))); ChangeLookAndFeel(Configure.getProperty("LookAndFeel")); SetWriteFormat(Configure.getProperty("WriteFormat")); SetAddR(Configure.getProperty("AddR")); SetAddN(Configure.getProperty("AddN")); SetReadMode(Configure.getProperty("ReadMode")); SetReadFormat(Configure.getProperty("ReadFormat")); SetFix8Bit(Configure.getProperty("Fix8Bit")); SetFixCapitalLetter(Configure.getProperty("FixCapitalLetter")); SetAddFormatRepresentation(Configure.getProperty("AddFormatRepresentation")); SetModeSelected(Configure.getProperty("ModeSelected")); } private void MessageboxShow(String string){ JOptionPane.showMessageDialog(rootPane, string); } private void SetModeSelected(String str){ //JOptionPane.showMessageDialog(rootPane, str); if (str.equals("Separate")){ SeparateModeSelectMenuButton.doClick(); }else if (str.equals("Terminal")){ TerminalModeSelectMenuButton.doClick(); } } private void SetAddFormatRepresentation(String str){ //MessageboxShow(str); if (str.equals("True")){ AddFormatRepresentationSelectMenuCheckBox.doClick(); }else if (str.equals("False")){ } } private void SetFixCapitalLetter(String str){ if (str.equals("True")){ FixCapitalLetterSelectMenuCheckBox.doClick(); }else if (str.equals("False")){ } } private void SetFix8Bit(String str){ if (str.equals("True")){ Fix8BitSelectMenuCheckBox.doClick(); }else if (str.equals("False")){ } } private void SetReadFormat(String str){ if (str.equals("String")){ ReadStrSelectMenuButton.doClick(); }else if (str.equals("Bin")){ ReadBinSelectMenuButton.doClick(); }else if (str.equals("Oct")){ ReadOctSelectMenuButton.doClick(); }else if (str.equals("Dec")){ ReadDecSelectMenuButton.doClick(); }else if (str.equals("Hex")){ ReadHexSelectMenuButton.doClick(); } } private void SetReadMode(String str){ if (str.equals("Read")){ ReadSelectMenuButton.doClick(); }else if (str.equals("ReadLine")){ ReadLineSelectMenuButton.doClick(); } } private void SetAddN(String str){ if (str.equals("True")){ AddNSelectMenuCheckBox.doClick(); }else if (str.equals("False")){ } } private void SetAddR(String str){ if (str.equals("True")){ AddRSelectMenuCheckBox.doClick(); }else if (str.equals("False")){ } } private void SetWriteFormat(String str){ //JOptionPane.showMessageDialog(rootPane, str); if (str.equals("String")){ WriteStrSelectMenuButton.doClick(); }else if (str.equals("Bin")){ WriteBinSelectMenuButton.doClick(); }else if (str.equals("Oct")){ WriteOctSelectMenuButton.doClick(); }else if (str.equals("Dec")){ WriteDecSelectMenuButton.doClick(); }else if (str.equals("Hex")){ WriteHexSelectMenuButton.doClick(); } } private void LafMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LafMenuItemActionPerformed AvailableLaf(); LafDialog.setSize(500, 120); LafDialog.setLocationRelativeTo(null); LafDialog.setVisible(true); }//GEN-LAST:event_LafMenuItemActionPerformed private void LafDialogCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LafDialogCloseButtonActionPerformed LafDialog.dispose(); }//GEN-LAST:event_LafDialogCloseButtonActionPerformed private void LafComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_LafComboBoxItemStateChanged LafDialogApplyButton.setEnabled(true); }//GEN-LAST:event_LafComboBoxItemStateChanged private void LafDialogApplyButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LafDialogApplyButtonMouseClicked LafDialogApplyButton.setEnabled(false); ChangeLookAndFeel(LafComboBox.getSelectedItem().toString()); FileSave(); }//GEN-LAST:event_LafDialogApplyButtonMouseClicked private void MaceWinduCloseMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MaceWinduCloseMenuItemActionPerformed this.dispose(); }//GEN-LAST:event_MaceWinduCloseMenuItemActionPerformed private void AboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AboutMenuItemActionPerformed AboutDialog.setSize(400, 300); AboutDialog.setLocationRelativeTo(null); AboutDialog.setVisible(true); }//GEN-LAST:event_AboutMenuItemActionPerformed private void AboutDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AboutDialogOkButtonActionPerformed AboutDialog.dispose(); }//GEN-LAST:event_AboutDialogOkButtonActionPerformed private void TerminalModeSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TerminalModeSelectMenuButtonActionPerformed if (TerminalModeSelectMenuButton.isSelected() == true){ TerminalModeChange(); if (Init == true){ FileSave(); } } }//GEN-LAST:event_TerminalModeSelectMenuButtonActionPerformed private void TerminalModeChange(){ RecievedDataTextArea.setEditable(false); RecievedDataTextArea.setFocusable(true); WriteTextField.setEnabled(false); WriteButton.setEnabled(false); } private void RecievedDataTextAreaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_RecievedDataTextAreaKeyTyped //JOptionPane.showMessageDialog(rootPane, "Key Typed"); if (TerminalModeSelectMenuButton.isSelected() == true){ WriteStr(String.valueOf(evt.getKeyChar())); //RecievedDataTextArea.append(String.valueOf(evt.getKeyChar())); } }//GEN-LAST:event_RecievedDataTextAreaKeyTyped private void SeparateModeSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SeparateModeSelectMenuButtonActionPerformed if (SeparateModeSelectMenuButton.isSelected() == true){ SeparateModeChange(); if (Init == true){ FileSave(); } } }//GEN-LAST:event_SeparateModeSelectMenuButtonActionPerformed private void SeparateModeChange(){ RecievedDataTextArea.setEditable(false); RecievedDataTextArea.setFocusable(false); WriteTextField.setEnabled(true); WriteButton.setEnabled(true); } private void RefreshPortsListMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RefreshPortsListMenuItemActionPerformed try { COM.close(); } catch (Exception e) { } AvailableComPort(); }//GEN-LAST:event_RefreshPortsListMenuItemActionPerformed private void ClearRecievedDataMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearRecievedDataMenuItemActionPerformed RecievedDataTextArea.setText(null); }//GEN-LAST:event_ClearRecievedDataMenuItemActionPerformed private void WriteStrSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteStrSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_WriteStrSelectMenuButtonActionPerformed private void WriteBinSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteBinSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_WriteBinSelectMenuButtonActionPerformed private void WriteOctSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteOctSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_WriteOctSelectMenuButtonActionPerformed private void WriteDecSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteDecSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_WriteDecSelectMenuButtonActionPerformed private void WriteHexSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WriteHexSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_WriteHexSelectMenuButtonActionPerformed private void AddRSelectMenuCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddRSelectMenuCheckBoxActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_AddRSelectMenuCheckBoxActionPerformed private void AddNSelectMenuCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddNSelectMenuCheckBoxActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_AddNSelectMenuCheckBoxActionPerformed private void ReadSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadSelectMenuButtonActionPerformed if (Init == true){ FileSave(); CloseComPort(); OpenComPort(PortsComboBox.getSelectedItem().toString()); } }//GEN-LAST:event_ReadSelectMenuButtonActionPerformed private void ReadLineSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadLineSelectMenuButtonActionPerformed if (Init == true){ FileSave(); CloseComPort(); OpenComPort(PortsComboBox.getSelectedItem().toString()); } }//GEN-LAST:event_ReadLineSelectMenuButtonActionPerformed private void ReadStrSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadStrSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_ReadStrSelectMenuButtonActionPerformed private void ReadBinSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadBinSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_ReadBinSelectMenuButtonActionPerformed private void ReadOctSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadOctSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_ReadOctSelectMenuButtonActionPerformed private void ReadDecSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadDecSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_ReadDecSelectMenuButtonActionPerformed private void ReadHexSelectMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReadHexSelectMenuButtonActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_ReadHexSelectMenuButtonActionPerformed private void Fix8BitSelectMenuCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Fix8BitSelectMenuCheckBoxActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_Fix8BitSelectMenuCheckBoxActionPerformed private void FixCapitalLetterSelectMenuCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FixCapitalLetterSelectMenuCheckBoxActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_FixCapitalLetterSelectMenuCheckBoxActionPerformed private void AddFormatRepresentationSelectMenuCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddFormatRepresentationSelectMenuCheckBoxActionPerformed if (Init == true){ FileSave(); } }//GEN-LAST:event_AddFormatRepresentationSelectMenuCheckBoxActionPerformed public class SerialPortlistener implements SerialPortEventListener{ @Override public void serialEvent(SerialPortEvent e){ if (e.getEventType() == SerialPortEvent.DATA_AVAILABLE){ if (ReadSelectMenuButton.isSelected() == true){ Read(); } if (ReadLineSelectMenuButton.isSelected() == true){ ReadLine(); } } } } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new MaceWindu().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JDialog AboutDialog; private javax.swing.JButton AboutDialogOkButton; private javax.swing.JLabel AboutDialogVersionLabel; private javax.swing.JMenuItem AboutMenuItem; private javax.swing.JCheckBoxMenuItem AddFormatRepresentationSelectMenuCheckBox; private javax.swing.JCheckBoxMenuItem AddNSelectMenuCheckBox; private javax.swing.JCheckBoxMenuItem AddRSelectMenuCheckBox; public javax.swing.JComboBox BaudRateComboBox; private javax.swing.ButtonGroup ChangeLookAndFeelMenuButtonGroup; private javax.swing.JMenuItem ClearRecievedDataMenuItem; public javax.swing.JComboBox DataBitsComboBox; private javax.swing.JMenu FileMenu; private javax.swing.JCheckBoxMenuItem Fix8BitSelectMenuCheckBox; private javax.swing.JCheckBoxMenuItem FixCapitalLetterSelectMenuCheckBox; public javax.swing.JComboBox FlowControlComboBox; private javax.swing.JComboBox LafComboBox; private javax.swing.JDialog LafDialog; private javax.swing.JButton LafDialogApplyButton; private javax.swing.JButton LafDialogCloseButton; private javax.swing.JMenuItem LafMenuItem; private javax.swing.JMenuItem MaceWinduCloseMenuItem; private javax.swing.JMenu ModeSelectMenu; private javax.swing.ButtonGroup ModeSelectMenuButtonGroup; public javax.swing.JLabel MsgLabel; public javax.swing.JComboBox ParityComboBox; public javax.swing.JComboBox PortsComboBox; private javax.swing.JRadioButtonMenuItem PressAnyKeySelectMenuButton; private javax.swing.JRadioButtonMenuItem PressReturnKeySelectMenuButton; private javax.swing.JRadioButtonMenuItem ReadBinSelectMenuButton; private javax.swing.JRadioButtonMenuItem ReadDecSelectMenuButton; private javax.swing.JMenu ReadFormatSelectMenu; private javax.swing.ButtonGroup ReadFormatSelectMenuButtonGroup; private javax.swing.JRadioButtonMenuItem ReadHexSelectMenuButton; private javax.swing.JRadioButtonMenuItem ReadLineSelectMenuButton; private javax.swing.ButtonGroup ReadModeSelectMenuButtonGroup; private javax.swing.JRadioButtonMenuItem ReadOctSelectMenuButton; private javax.swing.JMenu ReadPreferenceMenu; private javax.swing.JRadioButtonMenuItem ReadSelectMenuButton; private javax.swing.JRadioButtonMenuItem ReadStrSelectMenuButton; private javax.swing.JTextArea RecievedDataTextArea; private javax.swing.JMenuItem RefreshPortsListMenuItem; private javax.swing.JRadioButtonMenuItem SeparateModeSelectMenuButton; public javax.swing.JComboBox StopBitsComboBox; private javax.swing.JRadioButtonMenuItem TerminalModeSelectMenuButton; private javax.swing.JMenu ToolsMenu; private javax.swing.JRadioButtonMenuItem WriteBinSelectMenuButton; private javax.swing.JButton WriteButton; private javax.swing.JRadioButtonMenuItem WriteDecSelectMenuButton; private javax.swing.ButtonGroup WriteFormatSelectMenuButtonGroup; private javax.swing.JRadioButtonMenuItem WriteHexSelectMenuButton; private javax.swing.JRadioButtonMenuItem WriteOctSelectMenuButton; private javax.swing.JMenu WritePreferenceMenu; private javax.swing.JRadioButtonMenuItem WriteStrSelectMenuButton; private javax.swing.JTextField WriteTextField; private javax.swing.JMenu WriteTriggerMenu; private javax.swing.ButtonGroup WriteTriggerSelectMenuButtonGroup; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables }