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
| public JButton getJButtonChooseDir() {
if (jButtonChooseDir == null) {
jButtonChooseDir = new JButton("Parcourir...");
jButtonChooseDir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (getJFileChooser().showOpenDialog(Main.this) == JFileChooser.APPROVE_OPTION)
getJTextFieldFile().setText(getJFileChooser().getSelectedFile().getAbsolutePath());
}
});
}
return jButtonChooseDir;
}
public JFileChooser getJFileChooser() {
if (jFileChooser == null) {
jFileChooser = new JFileChooser();
jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
return jFileChooser;
}
public JTextField getJTextFieldFile() {
if (jTextFieldFile == null)
jTextFieldFile = new JTextField();
return jTextFieldFile;
} |