📄 setchanneljdialog.java
字号:
/* * SetChannelJDialog.java * * Created on 2008年4月23日, 下午3:48 */package documenteditor;import java.util.Vector;import javax.swing.DefaultCellEditor;import javax.swing.DefaultComboBoxModel;import javax.swing.JComboBox;/** * * @author Administrator */public class SetChannelJDialog extends javax.swing.JDialog { /** Creates new form SetChannelJDialog */ private GPRSClientThread gct = null; public SetChannelJDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); for(int i=1;i<17;i++){ jTable1.getModel().setValueAt("第"+Integer.toString(i)+"通道", i-1, 0); } } public void InitDialog(Vector ItmeVector){ JComboBox ItmejComboBox = new JComboBox(); ItmejComboBox.setModel(new DefaultComboBoxModel(ItmeVector)); jTable1.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(ItmejComboBox)); JComboBox IsjComboBox = new JComboBox(); IsjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "是", "否"})); jTable1.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(IsjComboBox)); } public void SetItemTable(Vector ItmeVector,Vector IsVector){ for(int i=1;i<17;i++){ try{ String temp = (String)ItmeVector.get(i-1); jTable1.getModel().setValueAt(temp, i-1, 1); } catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) { jTable1.getModel().setValueAt("", i-1, 1); } } for(int i=1;i<17;i++){ try{ String temp = (String)IsVector.get(i-1); jTable1.getModel().setValueAt(temp, i-1, 2); } catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) { jTable1.getModel().setValueAt("", i-1, 2); } } } /** 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setName("Form"); // NOI18N jSplitPane1.setDividerLocation(300); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setEnabled(false); jSplitPane1.setName("jSplitPane1"); // NOI18N jScrollPane1.setName("jScrollPane1"); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null}, {null, null, null} }, new String [] { "通道", "监测项目", "是否监测" } )); jTable1.setName("jTable1"); // NOI18N jScrollPane1.setViewportView(jTable1); jSplitPane1.setLeftComponent(jScrollPane1); jPanel1.setName("jPanel1"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(documenteditor.DocumentEditorApp.class).getContext().getResourceMap(SetChannelJDialog.class); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setName("jButton1"); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(82, 82, 82) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 134, Short.MAX_VALUE) .addComponent(jButton2) .addGap(89, 89, 89)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton2) .addComponent(jButton1)) .addGap(19, 19, 19)) ); jSplitPane1.setRightComponent(jPanel1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: Vector ItmeVector = new Vector(); String TDSet = ""; for(int i=0;i<16;i++){ String temp = jTable1.getModel().getValueAt(i, 1).toString(); temp = temp.substring(0,temp.indexOf("--")); ItmeVector.add(temp); if(jTable1.getModel().getValueAt(i, 2).toString().equals("是")){ TDSet += "1"; }else{ TDSet += "0"; } } gct.SendMessage(Protocol_WR_WDC07A.ReturnSetItems(gct.getID().toString(), ItmeVector,gct.getST()).getBytes()); gct.SendMessage(Protocol_WR_WDC07A.ReturnGetItems(gct.getID().toString(),gct.getST()).getBytes()); gct.SendMessage(Protocol_WR_WDC07A.ReturnSetItemsSet(gct.getID().toString(), TDSet,gct.getST()).getBytes()); gct.SendMessage(Protocol_WR_WDC07A.ReturnGetItemsSet(gct.getID().toString(),gct.getST()).getBytes()); setVisible(false); }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: setVisible(false); }//GEN-LAST:event_jButton2ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { SetChannelJDialog dialog = new SetChannelJDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables public void setGct(GPRSClientThread gct) { this.gct = gct; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -