/* * To change this template, choose Tools | Templates * and open the template in the editor. * Configuration the Bluetooth port */ /* * SKDSSwingPortConfiguration.java * * Created on 19.05.2011, 19:05:07 */ package skdsswing; import org.oobd.base.port.ComPort_Win; import javax.swing.Action; import javax.swing.JComboBox; import java.awt.event.WindowEvent; //import skdsswing.bus.*; import skdsswing.transfer.TransferSpecification; /** * * @author maziar */ public class SKDSSwingPortConfiguration extends javax.swing.JDialog { private final String[] baudrate={"115200" }; private final String[] parity ={"None"}; private final String[] stopbits={"One"}; private final String[] databits={"8"}; private final String[] handshake ={"None"}; private final String[] portname={"COM1"}; private static boolean portConfOpenSelected = false; private static int intBaudrate; private ComPort_Win comreader; public static boolean getPortOpenSelected(){ return portConfOpenSelected; } public static void setPortOpenSelected(boolean value){ portConfOpenSelected = value; } /** Creates new form SKDSSwingPortConfiguration */ public SKDSSwingPortConfiguration(java.awt.Frame parent) { super(parent); initComponents(); jComboBoxBaudrate.setSelectedIndex(0); jComboBoxDatabits.setSelectedIndex(0); jComboBoxHandshake.setSelectedIndex(0); jComboBoxParity.setSelectedIndex(0); jComboBoxstopbits.setSelectedIndex(0); jComboBoxBaudrate.enableInputMethods(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jComboBoxParity = new javax.swing.JComboBox(); jComboBoxBaudrate = new javax.swing.JComboBox(); jComboBoxPortname = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jComboBoxstopbits = new javax.swing.JComboBox(); jLabel4 = new javax.swing.JLabel(); jComboBoxDatabits = new javax.swing.JComboBox(); jLabel5 = new javax.swing.JLabel(); jComboBoxHandshake = new javax.swing.JComboBox(); jLabel6 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTextAreaPortConf = new javax.swing.JTextArea(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setName("Form"); // NOI18N setResizable(false); jLabel1.setName("jLabel1"); // NOI18N jLabel2.setName("jLabel2"); // NOI18N jComboBoxParity.setModel(new javax.swing.DefaultComboBoxModel(parity)); jComboBoxParity.setName("jComboBoxParity"); // NOI18N jComboBoxBaudrate.setModel(new javax.swing.DefaultComboBoxModel(baudrate)); jComboBoxBaudrate.setName("jComboBoxBaudrate"); jComboBoxPortname.setModel(new javax.swing.DefaultComboBoxModel(portname)); jComboBoxPortname.setName("jComboBoxPortname"); jLabel3.setName("jLabel3"); // NOI18N jComboBoxstopbits.setModel(new javax.swing.DefaultComboBoxModel(stopbits)); jComboBoxstopbits.setName("jComboBoxstopbits"); jLabel4.setName("jLabel4"); // NOI18N jComboBoxDatabits.setModel(new javax.swing.DefaultComboBoxModel(databits)); jComboBoxDatabits.setName("jComboBoxDatabits"); jLabel5.setName("jLabel5"); // NOI18N jComboBoxHandshake.setModel(new javax.swing.DefaultComboBoxModel(handshake)); jComboBoxHandshake.setName("jComboBoxHandshake"); jLabel6.setName("jLabel6"); // NOI18N javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(skdsswing.SKDSSwingApp.class).getContext().getActionMap(SKDSSwingPortConfiguration.class, this); jButton1.setAction(actionMap.get("OkPortConfigurationDialog")); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(skdsswing.SKDSSwingApp.class).getContext().getResourceMap(SKDSSwingPortConfiguration.class); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setMaximumSize(new java.awt.Dimension(53, 23)); jButton1.setMinimumSize(new java.awt.Dimension(53, 23)); jButton1.setName("jButton1"); // NOI18N jButton2.setAction(actionMap.get("closePortConfigurationDialog")); // NOI18N jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N jButton3.setAction(actionMap.get("TestPortConfigurationButton")); // NOI18N jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N jButton3.setMaximumSize(new java.awt.Dimension(53, 23)); jButton3.setMinimumSize(new java.awt.Dimension(53, 23)); jButton3.setName("jButton3"); // NOI18N jScrollPane1.setName("jScrollPane1"); // NOI18N jTextAreaPortConf.setColumns(20); jTextAreaPortConf.setEditable(false); jTextAreaPortConf.setRows(5); jTextAreaPortConf.setName("jTextAreaPortConf"); // NOI18N jScrollPane1.setViewportView(jTextAreaPortConf); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel6)) .addGap(24, 24, 24) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jComboBoxDatabits, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxstopbits, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxBaudrate, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxParity, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxPortname, 0, 90, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addGap(18, 18, 18) .addComponent(jComboBoxHandshake, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(102, 102, 102) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 177, Short.MAX_VALUE) .addComponent(jButton2))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jComboBoxPortname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addGap(27, 27, 27) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jComboBoxBaudrate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jComboBoxParity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jComboBoxstopbits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jComboBoxDatabits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jComboBoxHandshake, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(23, 23, 23)) ); pack(); }// </editor-fold>//GEN-END:initComponents /* * Close the Portconfiguration dialog */ @org.jdesktop.application.Action public void closePortConfigurationDialog() { portConfOpenSelected = true; dispose(); } @org.jdesktop.application.Action public void OkPortConfigurationDialog() { Object m = this.jComboBoxBaudrate.getSelectedItem(); portConfOpenSelected = true; dispose(); } /* * to test the port */ @org.jdesktop.application.Action public void TestPortConfigurationButton(){ jTextAreaPortConf.setText("Test"); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JComboBox jComboBoxBaudrate; private javax.swing.JComboBox jComboBoxDatabits; private javax.swing.JComboBox jComboBoxHandshake; private javax.swing.JComboBox jComboBoxParity; private javax.swing.JComboBox jComboBoxPortname; private javax.swing.JComboBox jComboBoxstopbits; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextAreaPortConf; // End of variables declaration//GEN-END:variables }