[英]Why does showOpenDialog() open more file choosers?
I am trying to create a 'Save to' file chooser. 我正在尝试创建一个“保存到”文件选择器。 However when i execute the code and hit 'Open' a new filechooser window is opened. 但是当我执行代码并点击“打开”时,会打开一个新的filechooser窗口。 The code: 代码:
int val = jFileChooser1.showOpenDialog(null);
private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println(evt.getActionCommand());
int val = jFileChooser1.showOpenDialog(null);
if(val == jFileChooser1.APPROVE_OPTION){
File filePath = jFileChooser1.getSelectedFile();
directoryPath = filePath.toString();
System.out.println("Directory Path: " + directoryPath);
}else{
System.exit(0);
}
}
尝试使用showSaveDialog方法。
int val = jFileChooser1.showOpenDialog(parent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.