Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom JList Rendering

 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

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

Thanks In Advance,



DesiredDisplay.JPG
[Thumbnail for DesiredDisplay.JPG]
DesiredDisplayOfContents
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually we have our requirements like that. can any one provide some solution please .

Thanks in Advance
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not just use a JTree?
 
Brian Cole
Author
Ranch Hand
Posts: 907
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
untitled.JPG
[Thumbnail for untitled.JPG]
asRequired
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic