Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Cory Nelson   on May 27 In Java Category.

  
Question Answered By: Isaac Williams   on May 27

I was floored by the change  from AWT's list  box
to Swing's JList, also, when I first encountered
it.<br><br>Sun actually implemented Object Oriented design
principles because they saw that there was a whole lot more
complicated uses for the listbox than a simple component
could handle.<br><br>So they created the JList Swing
component to be a manager and a delegator. It delegates the
rendering to a cell renderer so that you can compose each
cell using your own rendering class. It delegates the
management of the list to a list model so that the JList
itself doesn't have to add, update and delete individual
cells. And it delegates the changes of content and
selection to event listeners. This explanation may not be
entirely accurate but it is close enough to send you
scurrying off to find more background.<br><br>There is a
bunch of detail here--way too much to include in this
post. So I will refer you to my favorite book on the
subject: Graphic Java 2 Mastering the JFC by David M.
Geary. I am sure there are other books but this one
seems to cover everything on Swing. It is volume 2 in
the Graphic Java Series. Other volumes cover AWT, and
advanced graphical topics.<br><br>If you cannot get your
hands on a copy, visit Richard Baldwin's tutorials for
some hands-on coding at
www.phrantic.com/scoop/tocadv.htm<br>look for the advanced
tutorials 209-212. There are
lots of other topics to explore here. When I want to
review a topic, I usually visit here.<br><br>From
Geary's book:<br>AWT.List Method ....... JList equivalent
(JList list)<br>int getItemCount ......
list.getModel.getSize()<br>void remove(int) ...... void
DefaultListModel.removeElementAt(int)<br>void removeAll() ...... void
setListData(null)<br>String getItem(int) ...
lit.getModel.getItemAt(int)<br><br>There are other equivalents but these match
your
request.<br><br>JList compares to JTree in flexibility and complexity
IMHO

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on From AWT to SWING Or get search suggestion and latest updates.


Tagged: