JList with toggable group headers
Asked Answered
L

1

1

Is it possible to do something like the following image in Java?

I understand that I would need to be using a multi columned list, with a custom cell renderer, in order to show the images of each list element. But my question is regards to Grouping the list elements, and using group headers...

image of a grouped list view

As you can see from the image above this comes from windows explorer and is exactly the type of grouped list view that I would be looking to do with a JList in Java.

Lugworm answered 12/9, 2011 at 21:9 Comment(2)
Maybe org.netbeans.swing.outline.Outline?Quinlan
@Quinlan Thats not really what I am looking for... Thats for trees/tables.Lugworm
U
1

I don't think I would use a JTable in this situation.

First of all, I'd use a simple JPanel with DesignGridLayout, something like the example demonstrated in DesignGridLayout showdown application, section "Dynamic Layouts", example "Example 4 - Same with indented rows".

In that example you'd have to change the icons used for the outline effect (triangles instead of chevrons in the example).

Then, I would create a DrivePane deriving from JPanel, that would contain the drive icon as a JLabel (with no text), the drive name as a JLabel, the size as a JProgress bar, the size as a JLabel. I would probably use GridBagLayout as the LayoutManager for DrivePane. That component would be used for every drive to show.

Uniform answered 13/9, 2011 at 5:2 Comment(2)
'I would use GridBagLayout', coming from you? Probably should remove DesignGrid from my list of highly recommended managers if it can't do this easily ... grinning :-)Lubberly
@Lubberly hehe very good ;-) I am all for "use the right tool for the job" and I don't think DesignGrid would be able to handle the drive panel which is a bit specific.Uniform

© 2022 - 2024 — McMap. All rights reserved.