这个,有n多方法实现,给你个例子,在界面上放个gif,先隐藏,开始查询时,显示,等查询完后再隐藏. 或者用后台任务的方法,这段代码,我是用netbeans产生的,如果手工写,还真不知道怎么写,.......... private class HandRunTask extends org.jdesktop.application.Task<Object, Void> { HandRunTask(org.jdesktop.application.Application app) { // Runs on the EDT. Copy GUI state that // doInBackground() depends on from parameters // to HandRunTask fields, here. super(app); } @Override protected Object doInBackground() { // Your Task's code here. This method runs // on a background thread, so don't reference // the Swing GUI from here. logger.info("开始手动执行任务... ...."); ...... return null; // return your result } @Override protected void succeeded(Object result) { // Runs on the EDT. Update the GUI based on // the result computed by doInBackground(). if (result.toString().equals("手动运行成功!")) { JOptionPane.showMessageDialog(mainPanel, result, "信息", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(mainPanel, result, "错误", JOptionPane.ERROR_MESSAGE); } } }
或者用后台任务的方法,这段代码,我是用netbeans产生的,如果手工写,还真不知道怎么写,..........
private class HandRunTask extends org.jdesktop.application.Task<Object, Void> {
HandRunTask(org.jdesktop.application.Application app) {
// Runs on the EDT. Copy GUI state that
// doInBackground() depends on from parameters
// to HandRunTask fields, here.
super(app);
}
@Override protected Object doInBackground() {
// Your Task's code here. This method runs
// on a background thread, so don't reference
// the Swing GUI from here.
logger.info("开始手动执行任务... ....");
......
return null; // return your result
}
@Override protected void succeeded(Object result) {
// Runs on the EDT. Update the GUI based on
// the result computed by doInBackground().
if (result.toString().equals("手动运行成功!")) {
JOptionPane.showMessageDialog(mainPanel, result, "信息", JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(mainPanel, result, "错误", JOptionPane.ERROR_MESSAGE);
}
}
}