Java SwingUtilities.invokeLater
.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
try{
ta.append("Searching Initiated at: "+datetime()+"n");
gui.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
task.execute();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
gui.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
});
//Enable the next stage in the YD process and disable the previously executed functions
clusAn.setEnabled(true);
open.setEnabled(false);
statCl.setEnabled(false);
}catch (Exception IOE){
}
}
});
嗨,我设计的这个应用程序的最后阶段有点痛苦。
基本上,当用户点击按钮时,我会喜欢它,所以光标变成'等待'版本,然后一旦后台进程(task.execute)完成,光标就会恢复正常。
task.execute不在同一个类中,因此我不能直接调用“gui.setCursor”,因为它不能将GUI识别为变量。
不知道该怎么做,所以任何建议都会很棒
感谢:D
没有找到相关结果
已邀请:
3 个回复
抹持奠糙驰
方法。 你应该使用SwingWorker来做这种事情。 编辑: 以下是任务代码的编写方式:
弓萍功
杭难插