После открытия JFileChooser с помощью кнопки в окне открывается File Chooser, затем открывается окно оригинала. Я хотел бы оставить это оригинальное окно открытым, когда пользователь использует File Chooser и после.Java Swing: как открыть родительское окно после закрытия JFileChooser
Мой код:
// Code from the class that makes the original window that has the launch button
FilePicker filePicker = new FilePicker();
public void actionPerformed(ActionEvent e) {
txtImportLog.append("\nUser selecting file");
if (filePicker.canPick()) {
filePicker.init();
filePicker.getImportFile();
} else {
txtImportLog.append("\nCan't pick more files.");
}
}
});
// Code from the class that creates a FilePicker
//(yes, I know the getImportFile() and init() methods are setup badly, its just for
// testing right now
// Initialize - only should be called once
public void init() {
filePicker = new JFileChooser();
interval1 = 0;
interval2 = 0;
testFile = new File(""); // for testing. clearly.
}
// Get a file to import
public static File getImportFile() {
filePicker.setFileSelectionMode(JFileChooser.FILES_ONLY);
filePicker.showOpenDialog(filePicker);
return filePicker.getSelectedFile();
}
Рассмотрите возможность предоставления [runnable example] (https://stackoverflow.com/help/mcve), который демонстрирует вашу проблему. Это приведет к меньшему путанице и лучшим ответам. – MadProgrammer