| 1 | package event.editor; |
|---|
| 2 | |
|---|
| 3 | import java.awt.event.*; |
|---|
| 4 | import javax.swing.*; |
|---|
| 5 | |
|---|
| 6 | /** |
|---|
| 7 | * |
|---|
| 8 | * @author nathaniellehrer |
|---|
| 9 | */ |
|---|
| 10 | public class AudioPanel extends javax.swing.JPanel implements RemoveablePanel { |
|---|
| 11 | |
|---|
| 12 | private ActionListener removeListener; |
|---|
| 13 | |
|---|
| 14 | /** Creates new form AudioPanel */ |
|---|
| 15 | public AudioPanel() { |
|---|
| 16 | initComponents(); |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | public void setRemoveListener(ActionListener listener) |
|---|
| 20 | { |
|---|
| 21 | removeListener = listener; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | /** This method is called from within the constructor to |
|---|
| 25 | * initialize the form. |
|---|
| 26 | * WARNING: Do NOT modify this code. The content of this method is |
|---|
| 27 | * always regenerated by the Form Editor. |
|---|
| 28 | */ |
|---|
| 29 | @SuppressWarnings("unchecked") |
|---|
| 30 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 31 | private void initComponents() { |
|---|
| 32 | |
|---|
| 33 | removeButton = new javax.swing.JButton(); |
|---|
| 34 | jLabel1 = new javax.swing.JLabel(); |
|---|
| 35 | audioText = new javax.swing.JTextField(); |
|---|
| 36 | jLabel2 = new javax.swing.JLabel(); |
|---|
| 37 | jFormattedTextField1 = new javax.swing.JFormattedTextField(); |
|---|
| 38 | browseButton = new javax.swing.JButton(); |
|---|
| 39 | |
|---|
| 40 | removeButton.setText("Remove"); |
|---|
| 41 | removeButton.setToolTipText("Removes this property"); |
|---|
| 42 | removeButton.addMouseListener(new java.awt.event.MouseAdapter() { |
|---|
| 43 | public void mouseClicked(java.awt.event.MouseEvent evt) { |
|---|
| 44 | removeThisProperty(evt); |
|---|
| 45 | } |
|---|
| 46 | }); |
|---|
| 47 | removeButton.addActionListener(new java.awt.event.ActionListener() { |
|---|
| 48 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
|---|
| 49 | removeButtonActionPerformed(evt); |
|---|
| 50 | } |
|---|
| 51 | }); |
|---|
| 52 | |
|---|
| 53 | jLabel1.setText("Audio File"); |
|---|
| 54 | |
|---|
| 55 | audioText.setToolTipText("The path to the audio file"); |
|---|
| 56 | |
|---|
| 57 | jLabel2.setText("Length"); |
|---|
| 58 | |
|---|
| 59 | jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance()))); |
|---|
| 60 | |
|---|
| 61 | browseButton.setText("Browse"); |
|---|
| 62 | browseButton.setToolTipText("Browse for the audio file"); |
|---|
| 63 | browseButton.addMouseListener(new java.awt.event.MouseAdapter() { |
|---|
| 64 | public void mouseClicked(java.awt.event.MouseEvent evt) { |
|---|
| 65 | browse(evt); |
|---|
| 66 | } |
|---|
| 67 | }); |
|---|
| 68 | |
|---|
| 69 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
|---|
| 70 | this.setLayout(layout); |
|---|
| 71 | layout.setHorizontalGroup( |
|---|
| 72 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 73 | .add(layout.createSequentialGroup() |
|---|
| 74 | .addContainerGap() |
|---|
| 75 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 76 | .add(org.jdesktop.layout.GroupLayout.TRAILING, removeButton) |
|---|
| 77 | .add(layout.createSequentialGroup() |
|---|
| 78 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 79 | .add(jLabel1) |
|---|
| 80 | .add(jLabel2)) |
|---|
| 81 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 82 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 83 | .add(layout.createSequentialGroup() |
|---|
| 84 | .add(audioText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 395, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 85 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 86 | .add(browseButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)) |
|---|
| 87 | .add(jFormattedTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)))) |
|---|
| 88 | .addContainerGap()) |
|---|
| 89 | ); |
|---|
| 90 | layout.setVerticalGroup( |
|---|
| 91 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 92 | .add(layout.createSequentialGroup() |
|---|
| 93 | .addContainerGap() |
|---|
| 94 | .add(removeButton) |
|---|
| 95 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 96 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 97 | .add(audioText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 98 | .add(jLabel1) |
|---|
| 99 | .add(browseButton)) |
|---|
| 100 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 101 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
|---|
| 102 | .add(jFormattedTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
|---|
| 103 | .add(jLabel2)) |
|---|
| 104 | .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
|---|
| 105 | ); |
|---|
| 106 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 107 | |
|---|
| 108 | private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed |
|---|
| 109 | // TODO add your handling code here: |
|---|
| 110 | }//GEN-LAST:event_removeButtonActionPerformed |
|---|
| 111 | |
|---|
| 112 | private void removeThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeThisProperty |
|---|
| 113 | if (removeListener != null) |
|---|
| 114 | { |
|---|
| 115 | removeListener.actionPerformed(new ActionEvent(this, 0, "")); |
|---|
| 116 | } |
|---|
| 117 | }//GEN-LAST:event_removeThisProperty |
|---|
| 118 | |
|---|
| 119 | private void browse(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_browse |
|---|
| 120 | JFileChooser browser = new JFileChooser(); |
|---|
| 121 | int returnVal = browser.showOpenDialog(this); |
|---|
| 122 | if(returnVal == JFileChooser.APPROVE_OPTION) { |
|---|
| 123 | audioText.setText(browser.getSelectedFile().getPath()); |
|---|
| 124 | } |
|---|
| 125 | }//GEN-LAST:event_browse |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 129 | private javax.swing.JTextField audioText; |
|---|
| 130 | private javax.swing.JButton browseButton; |
|---|
| 131 | private javax.swing.JFormattedTextField jFormattedTextField1; |
|---|
| 132 | private javax.swing.JLabel jLabel1; |
|---|
| 133 | private javax.swing.JLabel jLabel2; |
|---|
| 134 | private javax.swing.JButton removeButton; |
|---|
| 135 | // End of variables declaration//GEN-END:variables |
|---|
| 136 | |
|---|
| 137 | } |
|---|