如何启动需要从数据库检索初始数据5-10秒的应用程序?这是我目前所拥有的,但我不确定是否有更好的方法。我希望GUI和数据库访问在不同的线程中,以便GUI构建与数据检索同时进行。
public static void main(String[] args) {
final Controller controller = new Controller();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
View frame = new View();
controller.setView(frame);
}
});
Model model = new Model();
controller.setModel(model);
controller.getInitialData();
}
JTable
监听TableModel
的事件一样,您的整体UI应该监听来自模型的事件(例如“DB访问完成”)。 - Darien