source: tmcsimulator-scriptbuilder/trunk/src/event/editor/MaintenanceRadioPanel.java @ 140

Revision 140, 3.2 KB checked in by bmcguffin, 8 years ago (diff)

Fixed defect #67. Removing an event and then closing the event editor window no longer causes the program to hang; a null check for the event is encountered before taking action upon close of the window.

Line 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import scriptbuilder.structures.events.*;
6
7/**
8 *
9 * @author nathaniellehrer
10 */
11public class MaintenanceRadioPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
12{
13
14    private ActionListener removeListener;
15    private MaintenanceRadioEvent event;
16
17    /**
18     * Creates new form MaintenanceRadio
19     */
20    public MaintenanceRadioPanel()
21    {
22        initComponents();
23    }
24
25    public void getEventObject(I_ScriptEvent sei)
26    {
27        event = (MaintenanceRadioEvent) sei;
28        jTextArea1.setText(event.message);
29    }
30
31    public void update(Observable o, Object arg)
32    {
33        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
34    }
35
36    @Override
37    public boolean removeAssociatedEvent()
38    {
39        ((I_ScriptEvent) event).removeThis();
40        event = null;
41        return true;
42    }
43
44    @Override
45    public void uponClose()
46    {
47        if (event != null)
48        {
49            event.message = jTextArea1.getText();
50        }
51    }
52
53    /**
54     * This method is called from within the constructor to initialize the form.
55     * WARNING: Do NOT modify this code. The content of this method is always
56     * regenerated by the Form Editor.
57     */
58    @SuppressWarnings("unchecked")
59    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
60    private void initComponents() {
61
62        jScrollPane1 = new javax.swing.JScrollPane();
63        jTextArea1 = new javax.swing.JTextArea();
64        jLabel1 = new javax.swing.JLabel();
65
66        jTextArea1.setColumns(20);
67        jTextArea1.setRows(5);
68        jTextArea1.setToolTipText("The radio transmission");
69        jScrollPane1.setViewportView(jTextArea1);
70
71        jLabel1.setText("Transmission:");
72
73        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
74        this.setLayout(layout);
75        layout.setHorizontalGroup(
76            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
77            .add(layout.createSequentialGroup()
78                .addContainerGap()
79                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
80                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
81                    .add(jLabel1))
82                .addContainerGap())
83        );
84        layout.setVerticalGroup(
85            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
86            .add(layout.createSequentialGroup()
87                .addContainerGap()
88                .add(jLabel1)
89                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
90                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
91                .addContainerGap())
92        );
93    }// </editor-fold>//GEN-END:initComponents
94
95
96    // Variables declaration - do not modify//GEN-BEGIN:variables
97    private javax.swing.JLabel jLabel1;
98    private javax.swing.JScrollPane jScrollPane1;
99    private javax.swing.JTextArea jTextArea1;
100    // End of variables declaration//GEN-END:variables
101
102}
Note: See TracBrowser for help on using the repository browser.