import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
+import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
final JLabel lblOutputFileNamePattern = new JLabel();
fldOutputDir = new JTextField();
fldOutputFileNamePattern = new JTextField();
- btnOutputDir = new JButton();
cbOutputEnable = new JCheckBox();
cbOutputCommentOverlay = new JCheckBox();
cbOutputDisplayProgress = new JCheckBox();
lblOutputFileNamePattern.setText("ファイル名規則");
- btnOutputDir.setText("...");
+ btnOutputDir.addActionListener(
+ new FileChooseAction(ConfigDialog.this, JFileChooser.DIRECTORIES_ONLY, fldOutputDir));
cbOutputEnable.setText("変換");
// ファイル - 変換動画
private final JTextField fldOutputDir;
private final JTextField fldOutputFileNamePattern;
- private final JButton btnOutputDir;
+ private final JButton btnOutputDir = new JButton("...");
private final JCheckBox cbOutputEnable;
private final JCheckBox cbOutputCommentOverlay;
private final JCheckBox cbOutputDisplayProgress;
class DownloadLocationPanel extends JPanel {
final JTextField fldDir = new JTextField();
- final JButton btnDir = new JButton("...");
final JTextField fldFileNamePattern = new JTextField();
final JCheckBox cbLocal = new JCheckBox("local");
final JLabel lblVideoDir = new JLabel("保存フォルダ");
final JLabel lblVideoFileNamepattern = new JLabel("ファイル名規則");
+ final JButton btnDir = new JButton("...");
+ btnDir.addActionListener(
+ new FileChooseAction(DownloadLocationPanel.this, JFileChooser.DIRECTORIES_ONLY, fldDir));
+
final GroupLayout gl = new GroupLayout(this);
setLayout(gl);
gl.setHorizontalGroup(
--- /dev/null
+package yukihane.inqubus.gui;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import javax.swing.JFileChooser;
+import javax.swing.JTextField;
+
+/**
+ *
+ * @author user
+ */
+public class FileChooseAction implements ActionListener {
+
+ private final Component parent;
+ private final int fileSelectionMode;
+ private final JTextField textField;
+
+ public FileChooseAction(Component parent, int fileSelectionMode, JTextField field) {
+ this.parent = parent;
+ this.fileSelectionMode = fileSelectionMode;
+ this.textField = field;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ final JFileChooser fc = new JFileChooser();
+ fc.setFileSelectionMode(fileSelectionMode);
+ fc.setCurrentDirectory(new File(textField.getText()));
+ final int res = fc.showOpenDialog(parent);
+ if (res == JFileChooser.APPROVE_OPTION) {
+ textField.setText(fc.getSelectedFile().getPath());
+ }
+ }
+}