• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying data in a JTable

 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to display some information in a JTable in somewhat like a tree fashion. I am not sure how to go about it or if there is another way to approach this problem.

the table contain rows related to specific dates. However, each date has multiple events associated with them. The events need to be displayed in sorted order. This could have been accomplished by using an expandable row if I could make the date as the root and expand the roe when the users click the row to show show all relevant events. But my problem is, I need to show one of the events even when the row is collapsed.

so in initial state, the table should look like this

Date event
----- -------------
date1 +most important event
date2 +most important event

when the user clicks on the + sign, the table should display the following

Date event
------------------------
|-event 1
|-event 2
date1 -|-most important event
|-event 4
|-event 5
------------------------------------------
date2 +most important event
------------------------------------------

How can I accomplish this?

Please help!
[ September 15, 2007: Message edited by: Dalia Sultana ]
 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like my formatting didn't quite work on the second view of the table.
Just to clarify, the date1, date2 values are in the first column and the event lists are on the second column.
 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giving it another shot - please replace the dots with spaces.

Date..............event
------------------------
..............|-event 1
..............|-event 2
date1 ....-|-most important event
..............|-event 4
..............|-event 5
------------------------------------------
date2 ......+ most important event
------------------------------------------

[ September 15, 2007: Message edited by: Dalia Sultana ]

[ September 15, 2007: Message edited by: Dalia Sultana ]
[ September 15, 2007: Message edited by: Dalia Sultana ]
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems what you need is a TreeTable


You can download JXTreeTable from: SwingLabs
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!