Warning: Can't use blame annotator:
svn blame failed on trunk/src/event/editor/AudioPanel.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/event/editor/AudioPanel.java @ 92

Revision 92, 6.3 KB checked in by bmcguffin, 9 years ago (diff)

Removed superfluous "Remove" buttons on several panels.

Removed interface "RemovablePanel?" as it was no longer necessary or useful; removed related methods from classes implementing it.

RevLine 
1package event.editor;
2
3import java.awt.event.*;
4import java.util.Observable;
5import javax.swing.*;
6import scriptbuilder.structures.events.AudioEvent;
7import scriptbuilder.structures.events.I_ScriptEvent;
8
9/**
10 *
11 * @author nathaniellehrer
12 */
13public class AudioPanel extends javax.swing.JPanel implements I_ScriptEventEditorPanel
14{
15
16    private ActionListener removeListener;
17    private AudioEvent event;
18
19    /**
20     * Creates new form AudioPanel
21     */
22    public AudioPanel()
23    {
24        initComponents();
25
26    }
27
28    @Override
29    public void getEventObject(I_ScriptEvent sei)
30    {
31        event = (AudioEvent) sei;
32        audioFileText.setText(event.audioPath);
33        audioLengthText.setText(event.audioLength.toString());
34        audioFileText.addKeyListener(new KeyListener()
35        {
36
37            public void keyTyped(KeyEvent e)
38            {
39            }
40
41            public void keyPressed(KeyEvent e)
42            {
43                if (e.getKeyCode() == KeyEvent.VK_ENTER)
44                {
45                    event.audioPath = audioFileText.getText();
46                }
47            }
48
49            public void keyReleased(KeyEvent e)
50            {
51            }
52        });
53        audioLengthText.addKeyListener(new KeyListener()
54        {
55
56            public void keyTyped(KeyEvent e)
57            {
58            }
59
60            public void keyPressed(KeyEvent e)
61            {
62                if (e.getKeyCode() == KeyEvent.VK_ENTER)
63                {
64                    try
65                    {
66                        event.audioLength = Integer.parseInt(audioLengthText.getText());
67                    }
68                    catch (Exception ex)
69                    {
70
71                    }
72                }
73            }
74
75            public void keyReleased(KeyEvent e)
76            {
77            }
78        }
79        );
80    }
81
82    @Override
83    public void update(Observable o, Object arg)
84    {
85        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
86    }
87   
88    @Override
89    public boolean removeAssociatedEvent()
90    {
91        event.removeThis();
92        event = null;
93        return true;
94    }
95
96    /**
97     * This method is called from within the constructor to initialize the form.
98     * WARNING: Do NOT modify this code. The content of this method is always
99     * regenerated by the Form Editor.
100     */
101    @SuppressWarnings("unchecked")
102    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
103    private void initComponents()
104    {
105
106        jLabel1 = new javax.swing.JLabel();
107        audioFileText = new javax.swing.JTextField();
108        jLabel2 = new javax.swing.JLabel();
109        audioLengthText = new javax.swing.JFormattedTextField();
110        browseButton = new javax.swing.JButton();
111
112        jLabel1.setText("Audio File");
113
114        audioFileText.setToolTipText("The path to the audio file");
115
116        jLabel2.setText("Length");
117
118        audioLengthText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance())));
119
120        browseButton.setText("Browse");
121        browseButton.setToolTipText("Browse for the audio file");
122        browseButton.addMouseListener(new java.awt.event.MouseAdapter()
123        {
124            public void mouseClicked(java.awt.event.MouseEvent evt)
125            {
126                browse(evt);
127            }
128        });
129
130        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
131        this.setLayout(layout);
132        layout.setHorizontalGroup(
133            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
134            .add(layout.createSequentialGroup()
135                .addContainerGap()
136                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
137                    .add(jLabel1)
138                    .add(jLabel2))
139                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
140                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
141                    .add(layout.createSequentialGroup()
142                        .add(audioFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 395, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
143                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
144                        .add(browseButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE))
145                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE))
146                .addContainerGap())
147        );
148        layout.setVerticalGroup(
149            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
150            .add(layout.createSequentialGroup()
151                .add(41, 41, 41)
152                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
153                    .add(audioFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
154                    .add(jLabel1)
155                    .add(browseButton))
156                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
157                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
158                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
159                    .add(jLabel2))
160                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
161        );
162    }// </editor-fold>//GEN-END:initComponents
163
164    private void browse(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_browse
165        JFileChooser browser = new JFileChooser();
166        int returnVal = browser.showOpenDialog(this);
167        if (returnVal == JFileChooser.APPROVE_OPTION)
168        {
169            audioFileText.setText(browser.getSelectedFile().getPath());
170        }
171    }//GEN-LAST:event_browse
172
173
174    // Variables declaration - do not modify//GEN-BEGIN:variables
175    private javax.swing.JTextField audioFileText;
176    private javax.swing.JFormattedTextField audioLengthText;
177    private javax.swing.JButton browseButton;
178    private javax.swing.JLabel jLabel1;
179    private javax.swing.JLabel jLabel2;
180    // End of variables declaration//GEN-END:variables
181
182}
Note: See TracBrowser for help on using the repository browser.