File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Custom JList Rendering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Custom JList Rendering" Watch "Custom JList Rendering" New topic
Author

Custom JList Rendering

Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Hi ,

I am new to Swings Programming.Iwant to display the contents of JList in the below specified way :

States:

Tamilnadu
Karnataka
AndhraPradesh
Kerala
UttarPradesh
Cities :
Chennai
Hyderabad
Bangalore
Trivendrum
Games :
Cricket
Hockey
Tennis
Billiards
Want to segregate the contents of JList based on Respective catagories.
I have other three Jlists which contains Cities , States and Games separately.


Can any one suggest me any idea of how to do it.

Thanks in Advance.

Hari.K,<br />+919886082889
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Hi All ,

In continuation to my previous post , please see the screen shot to know the way i want to display.

Thanks In Advance,






[Thumbnail for DesiredDisplay.JPG]

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39550
    
  27
Wouldn't it make more sense to keep these in separate JList objects? What is the advantage of cramming different things into the same list?


Ping & DNS - updated with new look and Ping home screen widget
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Actually we have our requirements like that. can any one provide some solution please .

Thanks in Advance
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
i'm storing them in 3 different JLists only. But while displaying i have to display them in above mentioned manner.
can any one suggest me how to display the lists in specified manner.


Thanks In advance,
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
why not just use a JTree?
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Hareendranath Babu Kotha wrote:i'm storing them in 3 different JLists only. But while displaying i have to display them in above mentioned manner.
can any one suggest me how to display the lists in specified manner.



I guess I don't understand how it makes any sense to display them in the above-mentioned manner if you're storing them in 3 different JLists. If you explain this it helps us help you, because it's hard for us to suggest things that don't seem to make any sense.

That said, you should be able to make it look any way you want. What part are you having trouble with?

You should be able to make each list element look any way you want by setting a custom ListCellRenderer. You may also want to set a custom ListSelectionModel to prevent the list elements that serve as category headers from being selected.

bitguru blog
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Hi
As i said i'm having separate lists , i kept the code which i wrote. even though i'm having separate lists for separate categories i'm seeting them in only model called activeFiltersListModel , with right transfer button i'm adding the selected values from availableFiltersList to activeFiltersList and respective models of lists will be updated.


As i said i want to display the selected values in ActiveFilters Section with the way i specified.

Thanks in Advance,



[Thumbnail for untitled.JPG]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

Hareendranath,

can you please Use Code Tags in the future? It keeps your indentation, and makes it much easier to read code. I've editted your post to include them; can you see the difference?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: Custom JList Rendering
 
Similar Threads
Changing Jlist
using SMS to send jar/jad OTA
Applet using a graphical map
To load the data for the entire application
Problem with JScrollPane