输入不存在的文件后,JfileChooser不会关闭窗口

时间:2017-04-27 17:07:51

标签: java javafx

抱歉我的英文。我必须在javafx中写记事本。我打开新文件使用FileChooser。如果用户键入错误的文件名,我的程序必须显示通信和勒索类型正确的名称文件。但是当我选择打开按钮时,filechooser的窗口就会消失。我希望filechooser窗口不会消失,但用户可以再次键入正确的名称文件。

public void onActionOpenFile()  {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Otwórz plik");
    File file = fileChooser.showOpenDialog(new Stage());
    try {
        if (file.exists()) {
            ReadFile read = new ReadFile(file.getAbsoluteFile().toPath());
            read.readFile();
        } else {

        }
    }catch (NullPointerException e){
        e.getMessage();
    }




}

当我打开showOpen对话框并输入错误的名称文件时,我希望我的程序在Windows中作为记事本工作。

0 个答案:

没有答案