창에서 버튼을 사용하여 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();
}
문제를 설명하는 [실행 가능한 예제] (https://stackoverflow.com/help/mcve)를 제공하십시오. 이렇게하면 혼란이 줄어들고 더 나은 응답을 얻을 수 있습니다. – MadProgrammer