| 1 | package event.editor; |
|---|
| 2 | |
|---|
| 3 | import java.awt.event.*; |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * |
|---|
| 7 | * @author nathaniellehrer |
|---|
| 8 | */ |
|---|
| 9 | public class TowPanel extends javax.swing.JPanel implements RemoveablePanel { |
|---|
| 10 | |
|---|
| 11 | private ActionListener removeListener; |
|---|
| 12 | |
|---|
| 13 | /** Creates new form TowPanel */ |
|---|
| 14 | public TowPanel() { |
|---|
| 15 | initComponents(); |
|---|
| 16 | |
|---|
| 17 | confirmationNumber.addFocusListener(new FocusListener() { |
|---|
| 18 | |
|---|
| 19 | public void focusGained(FocusEvent e) { |
|---|
| 20 | help.setText("Confirmation number is formated as a telephone number. Example: (555)555-5555"); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | public void focusLost(FocusEvent e) { |
|---|
| 24 | help.setText(""); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | }); |
|---|
| 28 | |
|---|
| 29 | publicNumber.addFocusListener(new FocusListener() { |
|---|
| 30 | |
|---|
| 31 | public void focusGained(FocusEvent e) { |
|---|
| 32 | help.setText("Public number is formated as a telephone number. Example: (555)555-5555"); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | public void focusLost(FocusEvent e) { |
|---|
| 36 | help.setText(""); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | }); |
|---|
| 40 | |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | public void setRemoveListener(ActionListener listener) |
|---|
| 44 | { |
|---|
| 45 | removeListener = listener; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | /** This method is called from within the constructor to |
|---|
| 49 | * initialize the form. |
|---|
| 50 | * WARNING: Do NOT modify this code. The content of this method is |
|---|
| 51 | * always regenerated by the Form Editor. |
|---|
| 52 | */ |
|---|
| 53 | @SuppressWarnings("unchecked") |
|---|
| 54 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 55 | private void initComponents() { |
|---|
| 56 | |
|---|
| 57 | removeButton = new javax.swing.JButton(); |
|---|
| 58 | jLabel1 = new javax.swing.JLabel(); |
|---|
| 59 | jTextField1 = new javax.swing.JTextField(); |
|---|
| 60 | jLabel2 = new javax.swing.JLabel(); |
|---|
| 61 | confirmationNumber = new javax.swing.JFormattedTextField(); |
|---|
| 62 | jLabel3 = new javax.swing.JLabel(); |
|---|
| 63 | publicNumber = new javax.swing.JFormattedTextField(); |
|---|
| 64 | jLabel4 = new javax.swing.JLabel(); |
|---|
| 65 | jTextField2 = new javax.swing.JTextField(); |
|---|
| 66 | help = new javax.swing.JLabel(); |
|---|
| 67 | |
|---|
| 68 | removeButton.setText("Remove"); |
|---|
| 69 | removeButton.addMouseListener(new java.awt.event.MouseAdapter() { |
|---|
| 70 | public void mouseClicked(java.awt.event.MouseEvent evt) { |
|---|
| 71 | removeThisProperty(evt); |
|---|
| 72 | } |
|---|
| 73 | }); |
|---|
| 74 | removeButton.addActionListener(new java.awt.event.ActionListener() { |
|---|
| 75 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
|---|
| 76 | removeButtonActionPerformed(evt); |
|---|
| 77 | } |
|---|
| 78 | }); |
|---|
| 79 | |
|---|
| 80 | jLabel1.setText("Company"); |
|---|
| 81 | |
|---|
| 82 | jLabel2.setText("Confirmation Number"); |
|---|
| 83 | |
|---|
| 84 | try { |
|---|
| 85 | confirmationNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); |
|---|
| 86 | } catch (java.text.ParseException ex) { |
|---|
| 87 | ex.printStackTrace(); |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | jLabel3.setText("Public Number"); |
|---|
| 91 | |
|---|
| 92 | try { |
|---|
| 93 | publicNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); |
|---|
| 94 | } catch (java.text.ParseException ex) { |
|---|
| 95 | ex.printStackTrace(); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | jLabel4.setText("Beat"); |
|---|
| 99 | |
|---|
| 100 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
|---|
| 101 | this.setLayout(layout); |
|---|
| 102 | layout.setHorizontalGroup( |
|---|
| 103 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 104 | .add(layout.createSequentialGroup() |
|---|
| 105 | .addContainerGap() |
|---|
| 106 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 107 | .add(help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE) |
|---|
| 108 | .add(org.jdesktop.layout.GroupLayout.TRAILING, removeButton) |
|---|
| 109 | .add(layout.createSequentialGroup() |
|---|
| 110 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 111 | .add(jLabel1) |
|---|
| 112 | .add(jLabel2) |
|---|
| 113 | .add(jLabel3) |
|---|
| 114 | .add(jLabel4)) |
|---|
| 115 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 116 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 117 | .add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 118 | .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 119 | .add(confirmationNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) |
|---|
| 120 | .add(publicNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)))) |
|---|
| 121 | .addContainerGap()) |
|---|
| 122 | ); |
|---|
| 123 | layout.setVerticalGroup( |
|---|
| 124 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 125 | .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
|---|
| 126 | .addContainerGap() |
|---|
| 127 | .add(removeButton) |
|---|
| 128 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) |
|---|
| 129 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 130 | .add(jLabel1) |
|---|
| 131 | .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 132 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 133 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 134 | .add(jLabel2) |
|---|
| 135 | .add(confirmationNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 136 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 137 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 138 | .add(jLabel3) |
|---|
| 139 | .add(publicNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 140 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 141 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 142 | .add(jLabel4) |
|---|
| 143 | .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
|---|
| 144 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE) |
|---|
| 145 | .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 146 | .addContainerGap()) |
|---|
| 147 | ); |
|---|
| 148 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 149 | |
|---|
| 150 | private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed |
|---|
| 151 | // TODO add your handling code here: |
|---|
| 152 | }//GEN-LAST:event_removeButtonActionPerformed |
|---|
| 153 | |
|---|
| 154 | private void removeThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeThisProperty |
|---|
| 155 | if (removeListener != null) |
|---|
| 156 | { |
|---|
| 157 | removeListener.actionPerformed(new ActionEvent(this, 0, "")); |
|---|
| 158 | } |
|---|
| 159 | }//GEN-LAST:event_removeThisProperty |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 163 | private javax.swing.JFormattedTextField confirmationNumber; |
|---|
| 164 | private javax.swing.JLabel help; |
|---|
| 165 | private javax.swing.JLabel jLabel1; |
|---|
| 166 | private javax.swing.JLabel jLabel2; |
|---|
| 167 | private javax.swing.JLabel jLabel3; |
|---|
| 168 | private javax.swing.JLabel jLabel4; |
|---|
| 169 | private javax.swing.JTextField jTextField1; |
|---|
| 170 | private javax.swing.JTextField jTextField2; |
|---|
| 171 | private javax.swing.JFormattedTextField publicNumber; |
|---|
| 172 | private javax.swing.JButton removeButton; |
|---|
| 173 | // End of variables declaration//GEN-END:variables |
|---|
| 174 | |
|---|
| 175 | } |
|---|