source: tmcsimulator-scriptbuilder/trunk/src/event/editor/TowPanel.java @ 7

Revision 7, 10.4 KB checked in by bmcguffin, 9 years ago (diff)

Renamed Interfaces in structures.events package from "*Interface" to "I_*"

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.I_ScriptEvent;
6import scriptbuilder.structures.events.TowEvent;
7
8/**
9 *
10 * @author nathaniellehrer
11 */
12public class TowPanel extends javax.swing.JPanel implements RemoveablePanel, 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    public void setRemoveListener(ActionListener listener)
58    {
59        removeListener = listener;
60    }
61
62    public void getEventObject(I_ScriptEvent sei)
63    {
64        event = (TowEvent) sei;
65        txtCompany.setText(event.towCompany);
66        txtCompany.addKeyListener(new KeyListener()
67        {
68            public void keyTyped(KeyEvent e)
69            {
70            }
71            public void keyPressed(KeyEvent e)
72            {
73                if (e.getKeyCode() == KeyEvent.VK_ENTER)
74                {
75                    event.towCompany = txtCompany.getText();
76                }
77            }
78            public void keyReleased(KeyEvent e)
79            {
80            }
81        });
82        txtBeat.setText(event.towBeat);
83        txtBeat.addKeyListener(new KeyListener()
84        {
85            public void keyTyped(KeyEvent e)
86            {
87            }
88            public void keyPressed(KeyEvent e)
89            {
90                if (e.getKeyCode() == KeyEvent.VK_ENTER)
91                {
92                    event.towBeat = txtBeat.getText();
93                }
94            }
95            public void keyReleased(KeyEvent e)
96            {
97            }
98        });
99        txtConfirmationNumber.setText("" + event.towConfNum);
100        txtConfirmationNumber.addKeyListener(new KeyListener()
101        {
102            public void keyTyped(KeyEvent e)
103            {
104            }
105            public void keyPressed(KeyEvent e)
106            {
107                if (e.getKeyCode() == KeyEvent.VK_ENTER)
108                {
109                    event.towConfNum = txtConfirmationNumber.getText();
110                }
111            }
112            public void keyReleased(KeyEvent e)
113            {
114            }
115        });
116        txtPublicNumber.setText("" + event.towPubNum);
117        txtPublicNumber.addKeyListener(new KeyListener()
118        {
119            public void keyTyped(KeyEvent e)
120            {
121            }
122            public void keyPressed(KeyEvent e)
123            {
124                if (e.getKeyCode() == KeyEvent.VK_ENTER)
125                {
126                    event.towPubNum = txtPublicNumber.getText();
127                }
128            }
129            public void keyReleased(KeyEvent e)
130            {
131            }
132        });
133    }
134
135    public void update(Observable o, Object arg)
136    {
137        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
138    }
139
140    /**
141     * This method is called from within the constructor to initialize the form.
142     * WARNING: Do NOT modify this code. The content of this method is always
143     * regenerated by the Form Editor.
144     */
145    @SuppressWarnings("unchecked")
146    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
147    private void initComponents()
148    {
149
150        removeButton = new javax.swing.JButton();
151        jLabel1 = new javax.swing.JLabel();
152        txtCompany = new javax.swing.JTextField();
153        jLabel2 = new javax.swing.JLabel();
154        txtConfirmationNumber = new javax.swing.JFormattedTextField();
155        jLabel3 = new javax.swing.JLabel();
156        txtPublicNumber = new javax.swing.JFormattedTextField();
157        jLabel4 = new javax.swing.JLabel();
158        txtBeat = new javax.swing.JTextField();
159        help = new javax.swing.JLabel();
160
161        removeButton.setText("Remove");
162        removeButton.addMouseListener(new java.awt.event.MouseAdapter()
163        {
164            public void mouseClicked(java.awt.event.MouseEvent evt)
165            {
166                removeThisProperty(evt);
167            }
168        });
169        removeButton.addActionListener(new java.awt.event.ActionListener()
170        {
171            public void actionPerformed(java.awt.event.ActionEvent evt)
172            {
173                removeButtonActionPerformed(evt);
174            }
175        });
176
177        jLabel1.setText("Company");
178
179        jLabel2.setText("Confirmation Number");
180
181        try
182        {
183            txtConfirmationNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####")));
184        } catch (java.text.ParseException ex)
185        {
186            ex.printStackTrace();
187        }
188
189        jLabel3.setText("Public Number");
190
191        try
192        {
193            txtPublicNumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####")));
194        } catch (java.text.ParseException ex)
195        {
196            ex.printStackTrace();
197        }
198
199        jLabel4.setText("Beat");
200
201        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
202        this.setLayout(layout);
203        layout.setHorizontalGroup(
204            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
205            .add(layout.createSequentialGroup()
206                .addContainerGap()
207                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
208                    .add(help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
209                    .add(org.jdesktop.layout.GroupLayout.TRAILING, removeButton)
210                    .add(layout.createSequentialGroup()
211                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
212                            .add(jLabel1)
213                            .add(jLabel2)
214                            .add(jLabel3)
215                            .add(jLabel4))
216                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
217                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
218                            .add(txtBeat, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
219                            .add(txtCompany, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
220                            .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
221                            .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE))))
222                .addContainerGap())
223        );
224        layout.setVerticalGroup(
225            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
226            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
227                .addContainerGap()
228                .add(removeButton)
229                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
230                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
231                    .add(jLabel1)
232                    .add(txtCompany, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
233                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
234                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
235                    .add(jLabel2)
236                    .add(txtConfirmationNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
237                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
238                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
239                    .add(jLabel3)
240                    .add(txtPublicNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
241                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
242                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
243                    .add(jLabel4)
244                    .add(txtBeat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
245                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE)
246                .add(help, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
247                .addContainerGap())
248        );
249    }// </editor-fold>//GEN-END:initComponents
250
251    private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
252        // TODO add your handling code here:
253    }//GEN-LAST:event_removeButtonActionPerformed
254
255    private void removeThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeThisProperty
256        if (removeListener != null)
257        {
258            removeListener.actionPerformed(new ActionEvent(this, 0, ""));
259        }
260    }//GEN-LAST:event_removeThisProperty
261
262
263    // Variables declaration - do not modify//GEN-BEGIN:variables
264    private javax.swing.JLabel help;
265    private javax.swing.JLabel jLabel1;
266    private javax.swing.JLabel jLabel2;
267    private javax.swing.JLabel jLabel3;
268    private javax.swing.JLabel jLabel4;
269    private javax.swing.JButton removeButton;
270    private javax.swing.JTextField txtBeat;
271    private javax.swing.JTextField txtCompany;
272    private javax.swing.JFormattedTextField txtConfirmationNumber;
273    private javax.swing.JFormattedTextField txtPublicNumber;
274    // End of variables declaration//GEN-END:variables
275
276}
Note: See TracBrowser for help on using the repository browser.