| 1 | package event.editor; |
|---|
| 2 | |
|---|
| 3 | import java.awt.event.*; |
|---|
| 4 | import java.util.Observable; |
|---|
| 5 | import scriptbuilder.structures.events.I_ScriptEvent; |
|---|
| 6 | import scriptbuilder.structures.events.TowEvent; |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * |
|---|
| 10 | * @author nathaniellehrer |
|---|
| 11 | */ |
|---|
| 12 | public class TowPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel |
|---|
| 13 | { |
|---|
| 14 | |
|---|
| 15 | private ActionListener removeListener; |
|---|
| 16 | private TowEvent event; |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | * Creates new form TowPanel |
|---|
| 20 | */ |
|---|
| 21 | public TowPanel() |
|---|
| 22 | { |
|---|
| 23 | initComponents(); |
|---|
| 24 | |
|---|
| 25 | txtConfirmationNumber.addFocusListener(new FocusListener() |
|---|
| 26 | { |
|---|
| 27 | |
|---|
| 28 | public void focusGained(FocusEvent e) |
|---|
| 29 | { |
|---|
| 30 | help.setText("Confirmation number is formated as a telephone number. Example: (555)555-5555"); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | public void focusLost(FocusEvent e) |
|---|
| 34 | { |
|---|
| 35 | help.setText(""); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | }); |
|---|
| 39 | |
|---|
| 40 | txtPublicNumber.addFocusListener(new FocusListener() |
|---|
| 41 | { |
|---|
| 42 | |
|---|
| 43 | public void focusGained(FocusEvent e) |
|---|
| 44 | { |
|---|
| 45 | help.setText("Public number is formated as a telephone number. Example: (555)555-5555"); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | public void focusLost(FocusEvent e) |
|---|
| 49 | { |
|---|
| 50 | help.setText(""); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | }); |
|---|
| 54 | |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | @Override |
|---|
| 58 | public void getEventObject(I_ScriptEvent sei) |
|---|
| 59 | { |
|---|
| 60 | event = (TowEvent) sei; |
|---|
| 61 | txtCompany.setText(event.towCompany); |
|---|
| 62 | txtCompany.addKeyListener(new KeyListener() |
|---|
| 63 | { |
|---|
| 64 | public void keyTyped(KeyEvent e) |
|---|
| 65 | { |
|---|
| 66 | } |
|---|
| 67 | public void keyPressed(KeyEvent e) |
|---|
| 68 | { |
|---|
| 69 | if (e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 70 | { |
|---|
| 71 | event.towCompany = txtCompany.getText(); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | public void keyReleased(KeyEvent e) |
|---|
| 75 | { |
|---|
| 76 | } |
|---|
| 77 | }); |
|---|
| 78 | txtBeat.setText(event.towBeat); |
|---|
| 79 | txtBeat.addKeyListener(new KeyListener() |
|---|
| 80 | { |
|---|
| 81 | public void keyTyped(KeyEvent e) |
|---|
| 82 | { |
|---|
| 83 | } |
|---|
| 84 | public void keyPressed(KeyEvent e) |
|---|
| 85 | { |
|---|
| 86 | if (e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 87 | { |
|---|
| 88 | event.towBeat = txtBeat.getText(); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | public void keyReleased(KeyEvent e) |
|---|
| 92 | { |
|---|
| 93 | } |
|---|
| 94 | }); |
|---|
| 95 | txtConfirmationNumber.setText("" + event.towConfNum); |
|---|
| 96 | txtConfirmationNumber.addKeyListener(new KeyListener() |
|---|
| 97 | { |
|---|
| 98 | public void keyTyped(KeyEvent e) |
|---|
| 99 | { |
|---|
| 100 | } |
|---|
| 101 | public void keyPressed(KeyEvent e) |
|---|
| 102 | { |
|---|
| 103 | if (e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 104 | { |
|---|
| 105 | event.towConfNum = txtConfirmationNumber.getText(); |
|---|
| 106 | } |
|---|
| 107 | } |
|---|
| 108 | public void keyReleased(KeyEvent e) |
|---|
| 109 | { |
|---|
| 110 | } |
|---|
| 111 | }); |
|---|
| 112 | txtPublicNumber.setText("" + event.towPubNum); |
|---|
| 113 | txtPublicNumber.addKeyListener(new KeyListener() |
|---|
| 114 | { |
|---|
| 115 | public void keyTyped(KeyEvent e) |
|---|
| 116 | { |
|---|
| 117 | } |
|---|
| 118 | public void keyPressed(KeyEvent e) |
|---|
| 119 | { |
|---|
| 120 | if (e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 121 | { |
|---|
| 122 | event.towPubNum = txtPublicNumber.getText(); |
|---|
| 123 | } |
|---|
| 124 | } |
|---|
| 125 | public void keyReleased(KeyEvent e) |
|---|
| 126 | { |
|---|
| 127 | } |
|---|
| 128 | }); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | @Override |
|---|
| 132 | public void update(Observable o, Object arg) |
|---|
| 133 | { |
|---|
| 134 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | @Override |
|---|
| 138 | public boolean removeAssociatedEvent() |
|---|
| 139 | { |
|---|
| 140 | event.removeThis(); |
|---|
| 141 | event = null; |
|---|
| 142 | return true; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | /** |
|---|
| 146 | * This method is called from within the constructor to initialize the form. |
|---|
| 147 | * WARNING: Do NOT modify this code. The content of this method is always |
|---|
| 148 | * regenerated by the Form Editor. |
|---|
| 149 | */ |
|---|
| 150 | @SuppressWarnings("unchecked") |
|---|
| 151 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 152 | private void initComponents() |
|---|
| 153 | { |
|---|
| 154 | |
|---|
| 155 | jLabel1 = new javax.swing.JLabel(); |
|---|
| 156 | txtCompany = new javax.swing.JTextField(); |
|---|
| 157 | jLabel2 = new javax.swing.JLabel(); |
|---|
| 158 | txtConfirmationNumber = new javax.swing.JFormattedTextField(); |
|---|
| 159 | jLabel3 = new javax.swing.JLabel(); |
|---|
| 160 | txtPublicNumber = new javax.swing.JFormattedTextField(); |
|---|
| 161 | jLabel4 = new javax.swing.JLabel(); |
|---|
| 162 | txtBeat = new javax.swing.JTextField(); |
|---|
| 163 | help = new javax.swing.JLabel(); |
|---|
| 164 | |
|---|
| 165 | jLabel1.setText("Company"); |
|---|
| 166 | |
|---|
| 167 | jLabel2.setText("Confirmation Number"); |
|---|
| 168 | |
|---|
| 169 | try |
|---|
| 170 | { |
|---|
| 171 | txtConfirmationNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); |
|---|
| 172 | } catch (java.text.ParseException ex) |
|---|
| 173 | { |
|---|
| 174 | ex.printStackTrace(); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | jLabel3.setText("Public Number"); |
|---|
| 178 | |
|---|
| 179 | try |
|---|
| 180 | { |
|---|
| 181 | txtPublicNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); |
|---|
| 182 | } catch (java.text.ParseException ex) |
|---|
| 183 | { |
|---|
| 184 | ex.printStackTrace(); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | jLabel4.setText("Beat"); |
|---|
| 188 | |
|---|
| 189 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
|---|
| 190 | this.setLayout(layout); |
|---|
| 191 | layout.setHorizontalGroup( |
|---|
| 192 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 193 | .add(layout.createSequentialGroup() |
|---|
| 194 | .addContainerGap() |
|---|
| 195 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 196 | .add(help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE) |
|---|
| 197 | .add(layout.createSequentialGroup() |
|---|
| 198 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 199 | .add(jLabel1) |
|---|
| 200 | .add(jLabel2) |
|---|
| 201 | .add(jLabel3) |
|---|
| 202 | .add(jLabel4)) |
|---|
| 203 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 204 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 205 | .add(txtBeat, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 206 | .add(txtCompany, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 207 | .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 208 | .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)))) |
|---|
| 209 | .addContainerGap()) |
|---|
| 210 | ); |
|---|
| 211 | layout.setVerticalGroup( |
|---|
| 212 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 213 | .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
|---|
| 214 | .add(47, 47, 47) |
|---|
| 215 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 216 | .add(jLabel1) |
|---|
| 217 | .add(txtCompany, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 218 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 219 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 220 | .add(jLabel2) |
|---|
| 221 | .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 222 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 223 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 224 | .add(jLabel3) |
|---|
| 225 | .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 226 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 227 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 228 | .add(jLabel4) |
|---|
| 229 | .add(txtBeat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 230 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE) |
|---|
| 231 | .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 232 | .addContainerGap()) |
|---|
| 233 | ); |
|---|
| 234 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 238 | private javax.swing.JLabel help; |
|---|
| 239 | private javax.swing.JLabel jLabel1; |
|---|
| 240 | private javax.swing.JLabel jLabel2; |
|---|
| 241 | private javax.swing.JLabel jLabel3; |
|---|
| 242 | private javax.swing.JLabel jLabel4; |
|---|
| 243 | private javax.swing.JTextField txtBeat; |
|---|
| 244 | private javax.swing.JTextField txtCompany; |
|---|
| 245 | private javax.swing.JFormattedTextField txtConfirmationNumber; |
|---|
| 246 | private javax.swing.JFormattedTextField txtPublicNumber; |
|---|
| 247 | // End of variables declaration//GEN-END:variables |
|---|
| 248 | |
|---|
| 249 | } |
|---|