File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList Problem

 
MIRANGA_H
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello !!!

I wanna load a dynamic list of value to a JList... That means the values that contain in the JList is not constants... it may change !!!
so how do i do this ???
 
Pat Hays
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call jList1.setListData(array) again.
 
Snoop One
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Well you should maybe look in to the model-view-controller architecture of swing.

Very brief intro:
http://www.unknownroad.com/rtfm/swingtut/mvc.html

The swing architecture:
http://java.sun.com/products/jfc/tsc/articles/architecture/

So what you need to do is to use a DefaultListModel as your data model and add any changes on the DefaultListModel object.
 
KR Campbell
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading the API for JList would be a good starting point:

"Simple dynamic-content JList applications can use the DefaultListModel class to store list elements."
 
KR Campbell
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pat Hays:
Call jList1.setListData(array) again.


..perhaps writing a ListDataListener would be a slightly more elegant approach!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic