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

Revision 171, 4.5 KB checked in by sdanthin, 6 years ago (diff)

AudioPanel?.form removed ability to edit the audio filename.
CHPRadioPanel.form removed ability to edit the audio filename.

Line 
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    @Override
28    public void getEventObject(I_ScriptEvent sei)
29    {
30        event = (AudioEvent) sei;
31        audioFileText.setText(event.audioPath);
32        audioLengthText.setText(event.audioLength.toString());
33    }
34
35    @Override
36    public void update(Observable o, Object arg)
37    {
38        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
39    }
40
41    @Override
42    public boolean removeAssociatedEvent()
43    {
44        event.removeThis();
45        event = null;
46        return true;
47    }
48
49    @Override
50    public void uponClose()
51    {
52        if (event != null)
53        {
54            event.audioPath = audioFileText.getText();
55            try
56            {
57                event.audioLength = Integer.parseInt(audioLengthText.getText());
58            }
59            catch (Exception ex)
60            {
61
62            }
63        }
64    }
65
66    /**
67     * This method is called from within the constructor to initialize the form.
68     * WARNING: Do NOT modify this code. The content of this method is always
69     * regenerated by the Form Editor.
70     */
71    @SuppressWarnings("unchecked")
72    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
73    private void initComponents() {
74
75        jLabel1 = new javax.swing.JLabel();
76        audioFileText = new javax.swing.JTextField();
77        jLabel2 = new javax.swing.JLabel();
78        audioLengthText = new javax.swing.JFormattedTextField();
79
80        jLabel1.setText("Audio File");
81
82        audioFileText.setToolTipText("The path to the audio file");
83        audioFileText.setEnabled(false);
84
85        jLabel2.setText("Length");
86
87        audioLengthText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance())));
88
89        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
90        this.setLayout(layout);
91        layout.setHorizontalGroup(
92            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
93            .add(layout.createSequentialGroup()
94                .addContainerGap()
95                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
96                    .add(jLabel1)
97                    .add(jLabel2))
98                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
99                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
100                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
101                    .add(audioFileText))
102                .addContainerGap())
103        );
104        layout.setVerticalGroup(
105            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
106            .add(layout.createSequentialGroup()
107                .add(44, 44, 44)
108                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
109                    .add(audioFileText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
110                    .add(jLabel1))
111                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
112                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
113                    .add(audioLengthText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
114                    .add(jLabel2))
115                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
116        );
117    }// </editor-fold>//GEN-END:initComponents
118
119
120    // Variables declaration - do not modify//GEN-BEGIN:variables
121    private javax.swing.JTextField audioFileText;
122    private javax.swing.JFormattedTextField audioLengthText;
123    private javax.swing.JLabel jLabel1;
124    private javax.swing.JLabel jLabel2;
125    // End of variables declaration//GEN-END:variables
126
127}
Note: See TracBrowser for help on using the repository browser.