Java 将JFileChooser与LWJGL一起使用
我试图将Java 将JFileChooser与LWJGL一起使用,java,image,file-io,lwjgl,jfilechooser,Java,Image,File Io,Lwjgl,Jfilechooser,我试图将JFileChooser与LWJGL一起使用,但是fileChooser.isDisplayable()返回false,我选中了,因为它不会弹出 这就是我用的 private void chooseFile(){ choose = new JFileChooser(); choose.setCurrentDirectory(new File(".")); choose.setFileSelectionMode(JFileChooser.FILES_AND_DIRE
JFileChooser
与LWJGL
一起使用,但是fileChooser.isDisplayable()
返回false,我选中了,因为它不会弹出
这就是我用的
private void chooseFile(){
choose = new JFileChooser();
choose.setCurrentDirectory(new File("."));
choose.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
choose.setFileFilter(new FileFilter(){
@Override
public boolean accept(File f) {
if(f.isDirectory()){
return true;
}
final String name = f.getName();
return name.endsWith(".png");
}
@Override
public String getDescription() {
return "*.png";
}
});
}
因此,如果有人对此有经验,或者只是大致知道为什么它不应该、不可能或永远不会工作,或者告诉我什么,那么我可以继续我的生活,找到其他解决方案,或者如果有人知道如何解决它。你永远不会告诉JFileChooser打开对话框。您需要调用
fileChooser.showOpenDialog()
或其他对话框方法之一(可以是打开/保存等)
这是一个简单的例子。要更快地获得更好的帮助,请发布一个。“谢谢你,罗斯。”不包括信号。有疑问。它们是噪音。我以为你必须选择一个父帧来调用它,但是使用
fileChooser.showOpenDialog(null)
到目前为止似乎可以工作,谢谢。你可以为它设置一个父帧,但将它设置为null将为它创建一个帧。很高兴我能帮忙!