Java gui与线程挂起

Java gui与线程挂起,java,multithreading,user-interface,Java,Multithreading,User Interface,我在java gui和打开文档时遇到问题。我的问题是,完整的gui会一直挂起,直到文档打开,但我已经将操作线程化了 我有一个动作监听器: this.EditButton.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent arg0) { String path = (String)DocumentsTabl

我在java gui和打开文档时遇到问题。我的问题是,完整的gui会一直挂起,直到文档打开,但我已经将操作线程化了

我有一个动作监听器:

    this.EditButton.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            String path = (String)DocumentsTable.getValueAt(DocumentsTable.getSelectedRow(), 2);
            openDocument(path);
            System.out.println("foo");
        }
    });
执行的操作只是打开给定的路径

private void openDocument(final String path){
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try{
                Desktop.getDesktop().open(new File(path));
            }
            catch(Exception e){
                JOptionPane.showMessageDialog(null, "Das Dokument konnte nicht geöffnet werden...\n"+e.toString());
                e.printStackTrace();
            }
        }
    });
}
如果我运行我的程序,我会立即在控制台上看到“foo”,但gui完全挂起,按钮处于按下状态。。。
有人知道我做错了什么吗?我的其他操作侦听器的工作方式与此相同,我没有问题…

SwingUtilities.invokeLater()
计划在EDT上运行runnable,如javadoc中所述。也许您应该使用
SwingWorker
打开文档?

为了简单起见,EDT==事件调度线程==gui线程