How to create an extensible list with Java Swing

I need to create an extensible list using java swing. I will try to demonstrate:

not common:

>[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” part in the list, other lists drop out, possibly containing more expandable lists. If you click on it again, this will lead to a reduction in "subscriptions". Pretty simple. And, as you can see, I am not looking for JComboBox, and I do not think JList can do this. If someone pointed me in the right direction or gave some programming examples, I would appreciate it.

Thanks MirroredFate

+6
source share
3 answers

How about using JTree .

A control that displays a set of hierarchical data in the form of a path.

+7
source

You can try using JTable and put the button in the first column. When the button is pressed, you add more data to the rows between them.

Update

Something like that:

with a tree

Or that

with a tabel

I think the first one uses JTree, but this idea.

By the way, these two belong to JIDE Soft, check if you can buy a license:

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

Not trivial to roll, but not impossible.

+2
source

check TreeTable or one example or Outline , but with a notification that on the official Java pages (SnOracle) any progress has died ...,

+1
source

Source: https://habr.com/ru/post/890793/


All Articles