This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
Similar Threads
Swing and pattern observer
I need help creating a custom ListModel
JList not refreshing ?issue?
JList : how to add one simple element to a existing list??
How to update JList