source: tmcsimulator-scriptbuilder/trunk/src/event/editor/CCTVPanel.java @ 1

Revision 1, 7.2 KB checked in by bmcguffin, 9 years ago (diff)

2017/07/18: Uploaded entire prototype to SVN repo.

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.CCTVEvent;
6import scriptbuilder.structures.events.ScriptEventInterface;
7
8/**
9 *
10 * @author nathaniellehrer
11 */
12public class CCTVPanel extends javax.swing.JPanel implements RemoveablePanel, ScriptEventEditorPanel
13{
14
15    private ActionListener removeListener;
16    private CCTVEvent event;
17
18    /**
19     * Creates new form CCTVInfoPanel
20     */
21    public CCTVPanel()
22    {
23        initComponents();
24
25        dir.addFocusListener(new FocusListener()
26        {
27
28            public void focusGained(FocusEvent e)
29            {
30                help.setText("Dir is an integer or decimal");
31            }
32
33            public void focusLost(FocusEvent e)
34            {
35                help.setText("");
36            }
37
38        });
39
40        toggle.addFocusListener(new FocusListener()
41        {
42
43            public void focusGained(FocusEvent e)
44            {
45                help.setText("toggle is an integer or decimal");
46            }
47
48            public void focusLost(FocusEvent e)
49            {
50                help.setText("");
51            }
52
53        });
54    }
55
56    public void setRemoveListener(ActionListener listener)
57    {
58        removeListener = listener;
59    }
60
61    public boolean isOptional()
62    {
63        return false;
64    }
65
66    public void getEventObject(ScriptEventInterface sei)
67    {
68        event = (CCTVEvent) sei;
69        //TODO: Add listeners for text fields
70    }
71
72    public void update(Observable o, Object arg)
73    {
74        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
75    }
76
77    /**
78     * This method is called from within the constructor to initialize the form.
79     * WARNING: Do NOT modify this code. The content of this method is always
80     * regenerated by the Form Editor.
81     */
82    @SuppressWarnings("unchecked")
83    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
84    private void initComponents() {
85
86        removeButton = new javax.swing.JButton();
87        jLabel1 = new javax.swing.JLabel();
88        dir = new javax.swing.JFormattedTextField();
89        jLabel3 = new javax.swing.JLabel();
90        jTextField1 = new javax.swing.JTextField();
91        jLabel2 = new javax.swing.JLabel();
92        toggle = new javax.swing.JFormattedTextField();
93        help = new javax.swing.JLabel();
94
95        removeButton.setText("Remove");
96        removeButton.addMouseListener(new java.awt.event.MouseAdapter() {
97            public void mouseClicked(java.awt.event.MouseEvent evt) {
98                removeButtonremoveThisProperty(evt);
99            }
100        });
101        removeButton.addActionListener(new java.awt.event.ActionListener() {
102            public void actionPerformed(java.awt.event.ActionEvent evt) {
103                removeButtonActionPerformed(evt);
104            }
105        });
106
107        jLabel1.setText("ID");
108
109        dir.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
110
111        jLabel3.setText("Toggle");
112
113        jLabel2.setText("Dir");
114
115        toggle.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
116
117        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
118        this.setLayout(layout);
119        layout.setHorizontalGroup(
120            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
121            .add(layout.createSequentialGroup()
122                .addContainerGap()
123                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
124                    .add(org.jdesktop.layout.GroupLayout.TRAILING, help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
125                    .add(org.jdesktop.layout.GroupLayout.TRAILING, removeButton)
126                    .add(layout.createSequentialGroup()
127                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
128                            .add(jLabel1)
129                            .add(jLabel2)
130                            .add(jLabel3))
131                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
132                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
133                            .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
134                            .add(dir, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
135                            .add(toggle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE))))
136                .addContainerGap())
137        );
138        layout.setVerticalGroup(
139            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
140            .add(layout.createSequentialGroup()
141                .addContainerGap()
142                .add(removeButton)
143                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
144                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
145                    .add(jLabel1)
146                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
147                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
148                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
149                    .add(jLabel2)
150                    .add(dir, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
151                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
152                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
153                    .add(jLabel3)
154                    .add(toggle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
155                .add(48, 48, 48)
156                .add(help, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 13, Short.MAX_VALUE)
157                .addContainerGap())
158        );
159    }// </editor-fold>//GEN-END:initComponents
160
161    private void removeButtonremoveThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeButtonremoveThisProperty
162        if (removeListener != null)
163        {
164            removeListener.actionPerformed(new ActionEvent(this, 0, ""));
165        }
166}//GEN-LAST:event_removeButtonremoveThisProperty
167
168    private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
169        // TODO add your handling code here:
170}//GEN-LAST:event_removeButtonActionPerformed
171
172
173    // Variables declaration - do not modify//GEN-BEGIN:variables
174    private javax.swing.JFormattedTextField dir;
175    private javax.swing.JLabel help;
176    private javax.swing.JLabel jLabel1;
177    private javax.swing.JLabel jLabel2;
178    private javax.swing.JLabel jLabel3;
179    private javax.swing.JTextField jTextField1;
180    private javax.swing.JButton removeButton;
181    private javax.swing.JFormattedTextField toggle;
182    // End of variables declaration//GEN-END:variables
183
184}
Note: See TracBrowser for help on using the repository browser.