1 package osm.jp.gpx.matchtime.gui;
3 import java.awt.event.ActionEvent;
5 import java.io.FileNotFoundException;
6 import javax.swing.JButton;
7 import javax.swing.JFileChooser;
9 @SuppressWarnings("serial")
10 public class ParameterPanelImageFile extends ParameterPanel {
12 public JButton openButton;
13 public ParameterPanelFolder paramDir;
15 @SuppressWarnings("OverridableMethodCallInConstructor")
16 public ParameterPanelImageFile(
17 String label, String text,
18 ParameterPanelFolder paramDir
23 SelectButtonAction buttonAction = new SelectButtonAction();
24 openButton = new JButton(i18n.getString("button.select"));
25 openButton.addActionListener(buttonAction);
28 //Create a file chooser
29 this.paramDir = paramDir;
32 class SelectButtonAction implements java.awt.event.ActionListener
34 @SuppressWarnings("override")
35 public void actionPerformed(ActionEvent e) {
36 selectImage_Action(e);
40 public void selectImage_Action(ActionEvent ev) {
41 File sdir = new File(paramDir.getText());
42 System.out.println(sdir.toPath());
43 if (sdir.isDirectory()) {
44 fc = new JFileChooser(sdir);
47 fc = new JFileChooser();
50 fc.addChoosableFileFilter(new ImageFilter());
51 fc.setAcceptAllFileFilterUsed(false);
52 fc.setFileView(new ImageFileView());
53 fc.setAccessory(new ImagePreview(fc));
56 int returnVal = fc.showDialog(ParameterPanelImageFile.this, i18n.getString("dialog.select"));
57 if (returnVal == JFileChooser.APPROVE_OPTION) {
58 File file = fc.getSelectedFile();
59 this.argField.setText(file.getName());
61 fc.setSelectedFile(null);
64 public File getImageFile() {
65 if (this.paramDir.isEnable()) {
66 String text = this.argField.getText();
69 File dir = this.paramDir.getDirectory();
70 File file = new File(dir, text);
71 if (file.exists() && file.isFile()) {
75 catch (FileNotFoundException e) {
88 public boolean isEnable() {
89 if (this.paramDir.isEnable()) {
90 String text = this.argField.getText();
93 File dir = this.paramDir.getDirectory();
94 File file = new File(dir, text);
95 if (file.exists() && file.isFile()) {
96 String name = file.getName().toUpperCase();
97 if (name.endsWith(".JPG") || name.endsWith(".JPEG")) {
102 catch (FileNotFoundException e) {