• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom JList Rendering

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not just use a JTree?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Hareendranath Babu Kotha
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic