-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDirectoryChooserS.java
More file actions
63 lines (52 loc) · 1.97 KB
/
DirectoryChooserS.java
File metadata and controls
63 lines (52 loc) · 1.97 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
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class DirectoryChooserS extends JFrame {
public DirectoryChooserS() {
super("Create Series");
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(Box.createVerticalGlue());
final JLabel label = new JLabel("Your directory");
label.setAlignmentX(CENTER_ALIGNMENT);
panel.add(label);
panel.add(Box.createRigidArea(new Dimension(10, 10)));
JButton button = new JButton("Create your directory");
button.setAlignmentX(CENTER_ALIGNMENT);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileopen = new JFileChooser();
int ret = fileopen.showDialog(null, "Create Series directory");
if (ret == JFileChooser.APPROVE_OPTION) {
File file = fileopen.getSelectedFile();
label.setText(file.getName());
}
}
});
panel.add(button);
panel.add(Box.createVerticalGlue());
getContentPane().add(panel);
setPreferredSize(new Dimension(260, 220));
pack();
setLocationRelativeTo(null);
setVisible(true);
}
public static void directoryChS() {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
// new DirectoryChooserS();
}
});
}
}