-
Notifications
You must be signed in to change notification settings - Fork 2
/
SelectInputFile.java
executable file
·140 lines (111 loc) · 5.25 KB
/
SelectInputFile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import java.io.*;
public class SelectInputFile extends WizardPanel {
private java.io.File selectedFile;
/** Creates new form SelectInputFile */
public SelectInputFile(String stepText) {
super(stepText);
initComponents();
// setFirstFocusable(selectButton);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
selectPanel = new javax.swing.JPanel();
imageTextField = new javax.swing.JTextField("");
selectButton = new javax.swing.JButton();
imageScrollPane = new javax.swing.JScrollPane();
audioLabel = new javax.swing.JLabel("" );
imagePreviewLabel = new javax.swing.JLabel("Audio preview");
playaudio=new javax.swing.JButton("Play Audio");
setLayout(new java.awt.BorderLayout());
selectPanel.setLayout(new java.awt.BorderLayout());
selectPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2));
imageTextField.setEditable(false);
selectPanel.add(playaudio,java.awt.BorderLayout.NORTH);
playaudio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
playaudioActionPerformed(evt);
}
});
selectPanel.add(imageTextField, java.awt.BorderLayout.CENTER);
selectButton.setMnemonic('F');
selectButton.setText("Select File");
selectButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
selectButtonActionPerformed(evt);
}
});
selectPanel.add(selectButton, java.awt.BorderLayout.EAST);
add(selectPanel, java.awt.BorderLayout.SOUTH);
audioLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
audioLabel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2));
// imageScrollPane.setViewportView(imageLabel);
add(imageScrollPane, java.awt.BorderLayout.CENTER);
audioLabel.setText("Play Audio");
System.out.println(audioLabel.getText());
//***audioLabel.setVisible(true);
imagePreviewLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
imagePreviewLabel.setText("Audio Preview");
add(imagePreviewLabel, java.awt.BorderLayout.NORTH);
}//GEN-END:initComponents
private void playaudioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
if(imageTextField.getText()==null)
{
javax.swing.JOptionPane.showMessageDialog(this,"Select an input file first");
}
else
{
System.out.println("Code to Play Audio...");
System.out.println("AudioFile Path"+ selectedFile.getParent());
System.out.println("AudioFile Name..."+ selectedFile.getName());
String url="file:///"+selectedFile.getParent()+"//";
System.out.println("URL.."+ url);
/*new SoundApplication("file:///C://Shri//AudioHide//Audio1.4//","music.au");*/
new SoundApplication(url,selectedFile.getName());
}
}
private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
// Add your handling code here:
javax.swing.JFileChooser chooser = GuiUtils.getImageFileChooser();
if(imageTextField.getText() != null)
chooser.setSelectedFile(new java.io.File(imageTextField.getText()));
if( chooser.showOpenDialog(this) == javax.swing.JFileChooser.APPROVE_OPTION){
selectedFile = chooser.getSelectedFile();
audioLabel.setText("Play File");
audioLabel.show();
audioLabel.setVisible(true);
//Icon(new javax.swing.ImageIcon(selectedFile.getAbsolutePath()));
imageTextField.setText(selectedFile.getAbsolutePath());
}
}//GEN-LAST:event_selectButtonActionPerformed
public boolean doValidation() {
if( imageTextField.getText().length() == 0 ) {
javax.swing.JOptionPane.showMessageDialog(this,"Select an input file");
selectButton.requestFocus();
return false;
}else if( ! new java.io.File(imageTextField.getText()).exists() ){
javax.swing.JOptionPane.showMessageDialog(this,"File not found! Select an valid file");
selectButton.requestFocus();
return false;
}
return true;
}
/** Getter for property selectedFile.
* @return Value of property selectedFile.
*/
public java.io.File getSelectedFile() {
return selectedFile;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField imageTextField;
private javax.swing.JPanel selectPanel;
private javax.swing.JLabel audioLabel;
private javax.swing.JScrollPane imageScrollPane;
private javax.swing.JButton selectButton;
private javax.swing.JLabel imagePreviewLabel;
private javax.swing.JButton playaudio;
// End of variables declaration//GEN-END:variables
}