Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an expandable list with Java Swing

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

like image 953
MirroredFate Avatar asked Jun 17 '11 21:06

MirroredFate


1 Answers

How about using a JTree.

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

like image 75
Marcelo Avatar answered Sep 19 '22 14:09

Marcelo