How to make an expandable list with Java Swing
Asked Answered
C

3

9

I need to make an expandable list using java swing. I will attempt to demonstrate:

Unexpanded:

 >[Expand me!]
 >[And me!]

Expanded:

 |[Expand me!]
     >[Expand us too!]
     >[Expand us too!]
     >[Expand us too!]
 >[And me!]

So, when you click on the "Expand me" portion of the list, another lists will drop down, possibly containing more expandable lists. If you were to click on it again, it's "sub-lists" would then retract. Pretty basic. And, as you can see, I am not looking for JComboBox, and I do not think JList can do this. If someone were to point me in the right direction, or give some programming examples, I would be grateful.

Thanks, MirroredFate

Concealment answered 17/6, 2011 at 21:37 Comment(0)
E
2

You can try using a JTable and put a button in the first column. When the button is clicked you add more data in the rows in between.

update

Something like this:

with a tree

Or this

with a tabel

I think the first uses a JTree but that the idea.

BTW these two belong to JIDE Soft, check if it is feasible for you to buy a license:

http://www.jidesoft.com/products/grids.htm

Is not trivial to roll you own but is not impossible either.

Eger answered 17/6, 2011 at 21:44 Comment(2)
why mozilla (today) didn't notify about concurency posts :-)Ralleigh
This is very powerful, but a bit to complex for my purposes.Concealment
D
8

How about using a JTree.

A control that displays a set of hierarchical data as an outline.

Dubiety answered 17/6, 2011 at 21:46 Comment(2)
This page has some examples.Malia
@Bala Thanks for the examples link. @Concealment No problem.Dubiety
E
2

You can try using a JTable and put a button in the first column. When the button is clicked you add more data in the rows in between.

update

Something like this:

with a tree

Or this

with a tabel

I think the first uses a JTree but that the idea.

BTW these two belong to JIDE Soft, check if it is feasible for you to buy a license:

http://www.jidesoft.com/products/grids.htm

Is not trivial to roll you own but is not impossible either.

Eger answered 17/6, 2011 at 21:44 Comment(2)
why mozilla (today) didn't notify about concurency posts :-)Ralleigh
This is very powerful, but a bit to complex for my purposes.Concealment
R
1

check for TreeTable or one example or Outline, but with notice, that on official Java (SnOracle) pages any progress died ...,

Ralleigh answered 17/6, 2011 at 22:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.