source: simplerunner/src/main/java/geniusweb/simplerunner/gui/MyFileChooser.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.2 KB
Line 
1package geniusweb.simplerunner.gui;
2
3import java.awt.BorderLayout;
4import java.awt.event.ActionEvent;
5import java.awt.event.ActionListener;
6
7import javax.swing.JButton;
8import javax.swing.JFileChooser;
9import javax.swing.JPanel;
10import javax.swing.JTextField;
11
12/**
13 * one-line panel with on left the chosen file and on the right a "Browse"
14 * button. If you click browse button you can browse for a file. You can also
15 * just type the file location.
16 *
17 */
18public class MyFileChooser extends JPanel {
19 private JTextField filenamearea = new JTextField("select a file");
20 private JButton browsebutton = new JButton("Browse");
21
22 public MyFileChooser() {
23 setLayout(new BorderLayout());
24 add(filenamearea, BorderLayout.CENTER);
25 add(browsebutton, BorderLayout.EAST);
26 browsebutton.addActionListener(new ActionListener() {
27
28 @Override
29 public void actionPerformed(ActionEvent e) {
30 JFileChooser fc = new JFileChooser();
31 int returnVal = fc.showOpenDialog(browsebutton);
32 if (returnVal == JFileChooser.APPROVE_OPTION) {
33 filenamearea
34 .setText(fc.getSelectedFile().getAbsolutePath());
35 }
36 }
37 });
38
39 }
40
41 public String getFile() {
42 return filenamearea.getText();
43 }
44}
Note: See TracBrowser for help on using the repository browser.