-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathSelector.java
More file actions
126 lines (96 loc) · 4.08 KB
/
PathSelector.java
File metadata and controls
126 lines (96 loc) · 4.08 KB
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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* PathSelector.java
*
* Created on Sep 21, 2009, 8:45:06 PM
*/
package mp3metagen;
/**
*
* @author stephenmalloy - stephendmalloy@gmail.com
*/
import java.awt.Frame;
import java.io.File;
import javax.swing.JFileChooser;
public class PathSelector extends javax.swing.JDialog {
String type;
Mp3ConvertGUI mainWindow;
/** Creates new form PathSelector */
public PathSelector(java.awt.Frame parent, boolean modal, String type, Mp3ConvertGUI parentWin) {
super(parent, modal);
this.type = type;
this.mainWindow = parentWin;
initComponents();
jFileChooser1.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Select Folder Path");
setAlwaysOnTop(true);
setModal(true);
setResizable(false);
jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFileChooser1ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
if (evt.getActionCommand().equals("CancelSelection")) {
this.dispose();
} else if (evt.getActionCommand().equals("ApproveSelection")) {
File file = jFileChooser1.getSelectedFile();
mainWindow.setPath( type, file.getAbsolutePath() );
dispose();
} else {
// ....
}
}//GEN-LAST:event_jFileChooser1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
PathSelector dialog = new PathSelector(new javax.swing.JFrame(), true, "", null);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JFileChooser jFileChooser1;
// End of variables declaration//GEN-END:variables
}