1 6 7 package com.nqadmin.swingSet.formatting; 8 9 import com.nqadmin.swingSet.SSDataNavigator; 10 import com.nqadmin.swingSet.datasources.SSRowSet; 11 import java.awt.Dimension ; 12 import java.awt.event.TextListener ; 13 import java.beans.Customizer ; 14 import java.beans.PropertyChangeListener ; 15 import java.beans.PropertyChangeSupport ; 16 import javax.swing.JComboBox ; 17 18 19 22 public class SSFormattedTextFieldCustomizer extends javax.swing.JPanel implements Customizer , TextListener { 23 24 private PropertyChangeSupport support = new PropertyChangeSupport (this); 25 private SSFormattedTextField ftf = null; 26 27 28 public SSFormattedTextFieldCustomizer() { 29 super(); 30 initComponents(); 31 32 } 33 34 public Dimension getPreferredSize() { 35 return new Dimension (400, 152); 36 } 37 38 39 public void addPropertyChangeListener(PropertyChangeListener l) { 40 support.addPropertyChangeListener(l); 41 } 42 43 public void removePropertyChangeListener(PropertyChangeListener l) { 44 support.removePropertyChangeListener(l); 45 } 46 47 public void setObject(Object bean) { 48 49 SSDataNavigator dn1 = null; 50 SSRowSet rs = null; 51 52 int n = 0; 53 54 ftf = (SSFormattedTextField)bean; 55 56 try { 57 58 rs = ftf.getSSRowSet(); 59 60 62 64 66 rs.execute(); 67 68 jTextField1.setText("execute"); 69 70 n = rs.getColumnCount(); 71 72 jTextField1.setText("getColumnCount"); 73 74 76 for (int i = 1; i <= n; i++) { 77 jComboBox3.addItem( rs.getColumnName(i)); 78 } 79 } catch (java.sql.SQLException se) { 80 jTextField1.setText("SQLException"); 81 se.printStackTrace(); 82 } catch (java.lang.NullPointerException np) { 83 np.printStackTrace(); 85 } catch (java.lang.Exception ex) { 86 jTextField1.setText("Exception"); 87 ex.printStackTrace(); 88 } finally { 89 jTextField2.setText(ftf.getColumnName()); 90 } 91 92 93 } 94 95 public void textValueChanged(java.awt.event.TextEvent e) { 96 } 97 98 103 private void initComponents() { jPanel1 = new javax.swing.JPanel (); 105 jLabel1 = new javax.swing.JLabel (); 106 jLabel2 = new javax.swing.JLabel (); 107 jComboBox1 = new javax.swing.JComboBox (); 108 jComboBox2 = new javax.swing.JComboBox (); 109 jLabel3 = new javax.swing.JLabel (); 110 jComboBox3 = new javax.swing.JComboBox (); 111 jTextField1 = new javax.swing.JTextField (); 112 jTextField2 = new javax.swing.JTextField (); 113 jCheckBox1 = new javax.swing.JCheckBox (); 114 115 FormListener formListener = new FormListener(); 116 117 setLayout(new java.awt.BorderLayout (2, 2)); 118 119 setMaximumSize(new java.awt.Dimension (400, 152)); 120 setMinimumSize(new java.awt.Dimension (400, 152)); 121 setName("SSFormattedTextField Customizer"); 122 jPanel1.setLayout(null); 123 124 jPanel1.setMaximumSize(new java.awt.Dimension (400, 152)); 125 jPanel1.setMinimumSize(new java.awt.Dimension (400, 152)); 126 jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 127 jLabel1.setText("SSDataNavigator : "); 128 jPanel1.add(jLabel1); 129 jLabel1.setBounds(20, 20, 130, 20); 130 131 jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 132 jLabel2.setText("SSRowSet : "); 133 jPanel1.add(jLabel2); 134 jLabel2.setBounds(30, 50, 120, 20); 135 136 jComboBox1.setEditable(true); 137 jPanel1.add(jComboBox1); 138 jComboBox1.setBounds(160, 20, 200, 20); 139 140 jComboBox2.setEditable(true); 141 jPanel1.add(jComboBox2); 142 jComboBox2.setBounds(160, 50, 200, 20); 143 144 jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 145 jLabel3.setText("Column Name : "); 146 jPanel1.add(jLabel3); 147 jLabel3.setBounds(30, 80, 120, 20); 148 149 jComboBox3.setEditable(true); 150 jComboBox3.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "<none>", "account_id", "account_name", "currency_id", "instructions" })); 151 jComboBox3.addActionListener(formListener); 152 153 jPanel1.add(jComboBox3); 154 jComboBox3.setBounds(160, 80, 200, 20); 155 156 jTextField1.addKeyListener(formListener); 157 158 jPanel1.add(jTextField1); 159 jTextField1.setBounds(160, 110, 90, 19); 160 161 jTextField2.setText("jTextField2"); 162 jPanel1.add(jTextField2); 163 jTextField2.setBounds(260, 110, 100, 19); 164 165 jCheckBox1.setText("jCheckBox1"); 166 jPanel1.add(jCheckBox1); 167 jCheckBox1.setBounds(30, 110, 98, 23); 168 169 add(jPanel1, java.awt.BorderLayout.CENTER); 170 171 } 172 173 175 private class FormListener implements java.awt.event.ActionListener , java.awt.event.KeyListener { 176 public void actionPerformed(java.awt.event.ActionEvent evt) { 177 if (evt.getSource() == jComboBox3) { 178 SSFormattedTextFieldCustomizer.this.jComboBox3ActionPerformed(evt); 179 } 180 } 181 182 public void keyPressed(java.awt.event.KeyEvent evt) { 183 } 184 185 public void keyReleased(java.awt.event.KeyEvent evt) { 186 if (evt.getSource() == jTextField1) { 187 SSFormattedTextFieldCustomizer.this.jTextField1KeyReleased(evt); 188 } 189 } 190 191 public void keyTyped(java.awt.event.KeyEvent evt) { 192 } 193 } 195 private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) { 199 JComboBox s = (JComboBox )(evt.getSource()); 200 201 String colName = null; 202 String oldName = null; 203 204 oldName = ftf.getColumnName(); 205 colName = ((String )(s.getSelectedItem())); 206 207 ftf.setColumnName(colName); 208 support.firePropertyChange("columnName", oldName, colName); 209 210 } 212 private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) { ftf.setColumnName(jTextField1.getText()); 215 firePropertyChange("columnName", null, jTextField1.getText()); 216 217 } 219 220 javax.swing.JCheckBox jCheckBox1; 222 javax.swing.JComboBox jComboBox1; 223 javax.swing.JComboBox jComboBox2; 224 javax.swing.JComboBox jComboBox3; 225 javax.swing.JLabel jLabel1; 226 javax.swing.JLabel jLabel2; 227 javax.swing.JLabel jLabel3; 228 javax.swing.JPanel jPanel1; 229 javax.swing.JTextField jTextField1; 230 javax.swing.JTextField jTextField2; 231 233 } 234 | Popular Tags |