aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JList & Observer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList & Observer" Watch "JList & Observer" New topic
Author

JList & Observer

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Guys,
I am developing simple chat application and I have a problem with JList:
ChatWindow extends JFrame implements Observer {
// ---
private JList onlineUsersList = new JList();
public ChatWindow() {
Container contentPane = getContentPane();
contentPane.add(new JScrollPane(onlineUsersList),
BorderLayout.EAST);
DefaultListModel model = new DefaultListModel();
onlineUsersList.setModel(model);
// ----
}

public void update(Observable obs, Object obj) {
final DefaultListModel model =
(DefaultListModel) onlineUsersList.getModel();
model.addElement("From update");
onlineUsersList.setModel(model);
}
}
What's wrong here ?
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList & Observer