Originally posted by Michael Dunn:
The 'space' occupied by each icon will equal that of the largest icon.
This wont take care of the scaling problem. If I understand the requirement correctly, all the icons of should be of a similar size which can be less than the size of some icons.
I would go for extending a JPanel, say an IconPanel which accepts an icon in the constructor and override the getPreferredSize() to return the required dimension.
This way instead of setting the grid layout and adding the icons, I would add the IconPanel. This way I will have solved the scaling problem. I will also have the flexibility regarding how to display the Icon, either of a label, button(in case some action needs to be taken on icon selection) or maybe even use the icon as the panel background.
Thus I have a parent panel which has a grid layout to which I have added various IconPanels. I noticed a JScrollBar in the original image. So while adding the parent panel I will have to use something like superParentContainer.add(new JScrollPane(parentPanel));