없이 Java GUI를 닫는 방법은 무엇입니까? dispose()을 사용하면 GUI가 닫히지 만 이후에는 다시 시작되지 않습니다. GUI를 사용하여 자동으로 카메라에서 디스크로 이미지를 작성하므로 GUI를 시작할 때마다이 작업을 반복해야합니다. 나중에이 GUI를 MATLAB에서 시작하기 위해 연결하려고합니다.System.exit을 사용하지 않고 Java GUI 닫기
public class MainWindow {
int fs_c = 1;
MainWindow() {
JFrame main_f = new JFrame("GUI");
main_f.getContentPane().setLayout(new BorderLayout());
main_f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
main_f.getContentPane().add(tabPane1, "Center");
//main_f.setSize(500, 620);
main_f.pack();
main_f.setVisible(true);
commandVal = 0;
while (true) {
if (fs_c == 1) {
commandVal = 5;
}
if (commandVal == 5 || commandVal == 6) {
cImage.sendFrame(0);
JFileChooser save_d = new JFileChooser();
File saveFile = save_d.getSelectedFile();
cImage.writeImage(saveFile + ".jpg");
fs_c = 0;
main_f.dispose();
} else if (commandVal == -1) {
stopCameraStuff();
}
}
}
}
고맙습니다! 이제는 GUI가 serial.dll을로드 할 때마다 또 다른 문제가 생깁니다. MATLAB은 "네이티브 라이브러리 C : \ serial.dll이 이미 다른 클래스 로더에로드되었습니다."라는 오류를줍니다. 이 문제도 해결하도록 도와 줄 수 있습니까? – Makaroni
@Makaroni : "네이티브 라이브러리 whatever.dll이 이미 다른 클래스 로더에로드되었습니다." 그래서 몇 번이나 대답을 한 것 같다 : http://stackoverflow.com/questions/3724421/native-library-already-loaded-in-another-classloader 대답과 여러 다른 링크가 있습니다. – millimoose