1 package osm.jp.gpx.matchtime.gui;
3 import java.awt.event.ActionEvent;
5 import javax.swing.JButton;
6 import javax.swing.JFileChooser;
8 @SuppressWarnings("serial")
9 public class ParameterPanelImageFile extends ParameterPanel {
11 public JButton openButton;
12 public ParameterPanelFolder paramDir;
14 @SuppressWarnings("OverridableMethodCallInConstructor")
15 public ParameterPanelImageFile(String label, String text, ParameterPanelFolder paramDir) {
19 openButton = new JButton(i18n.getString("button.select"));
20 openButton.addActionListener(this);
23 //Create a file chooser
24 this.paramDir = paramDir;
27 @SuppressWarnings("override")
28 public void actionPerformed(ActionEvent e) {
29 //Set up the file chooser.
30 File sdir = new File(paramDir.getText());
31 System.out.println(sdir.toPath());
32 if (sdir.isDirectory()) {
33 fc = new JFileChooser(sdir);
36 fc = new JFileChooser();
39 //Add a custom file filter and disable the default
40 //(Accept All) file filter.
41 fc.addChoosableFileFilter(new ImageFilter());
42 fc.setAcceptAllFileFilterUsed(false);
44 //Add custom icons for file types.
45 fc.setFileView(new ImageFileView());
47 //Add the preview pane.
48 fc.setAccessory(new ImagePreview(fc));
51 int returnVal = fc.showDialog(ParameterPanelImageFile.this, "選択");
53 //Process the results.
54 if (returnVal == JFileChooser.APPROVE_OPTION) {
55 File file = fc.getSelectedFile();
56 this.argField.setText(file.getName());
59 //Reset the file chooser for the next time it's shown.
60 fc.setSelectedFile(null);
68 public boolean isEnable() {
69 throw new UnsupportedOperationException("Not supported yet.");