这里面包含了一百多个JAVA源文件

源代码在线查看: e334. implementing a simple event notifier.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				The Observer and Observable classes are superseded by a more elaborate event framework (see e333 Creating a Custom Event). However, these two classes can still be useful for implementing a simple event notifier. 
				    // Declare the model
				    class MyModel extends Observable {
				        // The setChanged() protected method must overridden to make it public
				        public synchronized void setChanged() {
				            super.setChanged();
				        }
				    }
				
				    // Create the model
				    MyModel model = new MyModel();
				    
				    // Register for events
				    model.addObserver(new Observer() {
				        public void update(Observable o, Object arg) {
				        }
				    });
				    
				    // Indicate that the model has changed
				    model.setChanged();
				    
				    // Fire an event to all the views
				    Object arg = "some information about the event";
				    model.notifyObservers(arg);
				
							

相关资源