У меня есть JPanel с тремя кнопками J, которые открывают JFileChooser.
Когда я выбираю каждый файл, я просто хочу получить путь к файлу, чтобы впоследствии я мог открывать файл f1, f2, f3 один за другим, но не все вместе (т.е. закрывать один, открывать следующий).
Есть ли способ получить имя файла без вызова getSelectedFile ()?
Это убивает мою программу и просто зависает ...
Спасибо
public void actionPerformed(ActionEvent e) {
//Handle open button action.
if (e.getSource() == openActiveSKUsButton) {
int returnVal = fc.showOpenDialog(UI.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile(); // this is bad
ActiveSKUsFilePath = file.getAbsolutePath();
//This is where a real application would open the file.
log.append("Active SKUs file selected is: " + file.getName() + "." + newline);
file = null; //doesn't seem to work
System.gc(); //ditto as above
} else {
//log.append("Open command cancelled by user." + newline);
}
log.setCaretPosition(log.getDocument().getLength());
}
}