Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface JavaFX应用程序:创建用户反馈,表明程序仍在运行_User Interface_Javafx_Jaxb_Loading_No Response - Fatal编程技术网

User interface JavaFX应用程序:创建用户反馈,表明程序仍在运行

User interface JavaFX应用程序:创建用户反馈,表明程序仍在运行,user-interface,javafx,jaxb,loading,no-response,User Interface,Javafx,Jaxb,Loading,No Response,我正在开发一个从集合中读取XML文件并将信息写入文本文件的工具。这个过程可能需要几秒钟,我的程序在标题中得到“无响应” 有没有一种简单的方法来通知用户程序仍在运行?比如实现加载图像或带有标签的3点动画 我没有这方面的经验 这是读取文件和写入txt的当前方法: @FXML public void FullFilterAndExport() throws JAXBException, IOException { totalFilesCount = 0; totalFilesCoun

我正在开发一个从集合中读取XML文件并将信息写入文本文件的工具。这个过程可能需要几秒钟,我的程序在标题中得到“无响应”

有没有一种简单的方法来通知用户程序仍在运行?比如实现加载图像或带有标签的3点动画

我没有这方面的经验

这是读取文件和写入txt的当前方法:

@FXML
public void FullFilterAndExport() throws JAXBException, IOException {
    totalFilesCount = 0;
    totalFilesCountPositive = 0;
    PrintWriter pWriter = new PrintWriter(new BufferedWriter(new FileWriter(DB_Path.toString() + "\\export_full.txt")));        
    for(String file: FileList) {
        if (file.endsWith(".xml") && !file.contains("databaseinfo.xml")) {
            totalFilesCount = totalFilesCount +1;
            ItemList.clear();
            JAXBContext context = JAXBContext.newInstance(NotesDocumentMetaFile.class);
            Unmarshaller um = context.createUnmarshaller();
            NotesDocumentMetaFile docMetaFile = (NotesDocumentMetaFile) um.unmarshal(new FileReader(file));

            for(int i = 0; i < docMetaFile.getItems().size(); i++) {
                if(docMetaFile.getItems().get(i).getValueIsSpecial() == true) {
                    ItemList.add("Itemname:" + docMetaFile.getItems().get(i).getName());
                }
            }
            if(!ItemList.isEmpty()) {
                totalFilesCountPositive = totalFilesCountPositive + 1;
                pWriter.println(file);
                pWriter.println();
                for(String item : ItemList) {
                    pWriter.println(item);
                }
                pWriter.println();
            }

        }
    }
    pWriter.println();
    pWriter.println("------------------");
    pWriter.println("Anzahl der geprüften Dateien: " + totalFilesCount);
    pWriter.println("Anzahl der geprüften positiven Dateien: " + totalFilesCountPositive);
    if (pWriter != null){ 
        pWriter.flush(); 
        pWriter.close();
    }
}
@FXML
public void FullFilterAndExport()引发JAXBEException,IOException{
totalFilesCount=0;
TotalFileCountPositive=0;
PrintWriter pWriter=新的PrintWriter(新的缓冲写入程序(新的文件写入程序(DB_Path.toString()+“\\export_full.txt”));
for(字符串文件:文件列表){
if(file.endsWith(“.xml”)&&!file.contains(“databaseinfo.xml”)){
totalFilesCount=totalFilesCount+1;
ItemList.clear();
JAXBContext context=JAXBContext.newInstance(NotesDocumentMetaFile.class);
Unmarshaller um=context.createUnmarshaller();
NotesDocumentMetaFile docMetaFile=(NotesDocumentMetaFile)um.unmarshal(新文件读取器(文件));
对于(int i=0;i
处理此问题的方法对于所有类型的UI技术都是通用的:不要在UI线程中执行冗长的作业,而是为此目的生成后台线程。JavaFX通过
JavaFX.concurrent
包中的
Task
s和
Service
s支持此功能。谢谢。。。似乎是我要找的。。。你能提供一个上面代码的例子吗?此方法是控制器类的一部分,可通过按下按钮来触发。。。。到目前为止,我想我必须做一个额外的类,这将是服务<如果您想在UI中显示消息/进度,代码>任务也可能是一个很有前途的选项。。。