1
我有一个java gui的问题,并打开一个文件。我的问题是完整的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();
}
}
});
}
如果我跑我的节目,我立刻看到控制台上的“富”,但GUI完全地挂断和按钮处于按下状态... 有没有人有一个想法,我做错了什么?我的其他动作侦听器的工作原理是相同的,我没有问题...
为简单起见,EDT ==事件分派线程== gui线程 – Ishtar 2010-09-13 09:47:21
谢谢,它工作:)我应该将所有invokeLater更改为SwingWorkers ... – reox 2010-09-13 09:55:17