问题
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...
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.
回答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.
来源:https://stackoverflow.com/questions/7394079/jlist-with-toggable-group-headers