1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| if( e.getSource() == btnBrowseTarLocation)
{
try
{
// openinf of a dialog frame to seach the file
JFrame f = new JFrame();
FileDialog fd = new FileDialog (f, "Select the file to import", FileDialog.LOAD);
fd.setFile ("*.*");
fd.setVisible(true);
// variable in which the path of the selected file will be stocked
String fileDir = new String();
String directory = (fd.getDirectory()); // recuperation of the file directory
String fileName = (fd.getFile());
fileDir = directory+fileName;
txtTarLocation.setText(fileDir);
}
catch (IllegalArgumentException IlArgE)
{
JOptionPane.showMessageDialog(this, "Error with the file dialog", "Error", JOptionPane.ERROR_MESSAGE);
}
} |
Partager