MainWindow中开了一个线程来处理数据,当数据处理完了,我想让它通知Mainwindow来更新界面上的信息,怎么实现呢?
Java中是不是也有类似Windows的消息循环机制呢?用户能够重载自定义吗?
谢谢!PS. MainWindow 继承自JFrame.
Java中是不是也有类似Windows的消息循环机制呢?用户能够重载自定义吗?
谢谢!PS. MainWindow 继承自JFrame.
调试欢乐多
MainWindow开了个线程在处理数据,同时mainwindow弹出一个对话框告诉用户,现在在处理数据。当线程处理完数据后,我想让线程通知Mainwindow关掉弹出的对话框。所以我想为Mainwindow自定义一个消息,让线程把消息通知给MainWindow,再进行关闭。
不知道可不可行。
再继承一个windowListener类,处理事件
就OK了
java.util.Observable
java.util.Observer
Note that this notification mechanism is has nothing to do with threads and is completely separate from the wait and notify mechanism of class Object.