I've created actions manager, to create and get actions. I'm adding actions to tollbar (JToolbar) and menus (JMenu). Problem is with icons size. I need different size to menu icon, and bigger in toolbar.
I found solution to resize icon in tollbar, after it's created:
for (int i=0; i<mainToolbar.getComponents().length; i++) {
try {
JButton b = (JButton) mainToolbar.getComponent(i);
ImageIcon ii = (ImageIcon)b.getIcon();
Image im = ii.getImage().getScaledInstance(32, 32, 0);
b.setIcon(new ImageIcon(im));
} catch (ClassCastException ex) {}
}
The problem is, that I need smaller icons to menu, so if I create action with 16px size icon, then resize it this way to 32px, icon quality crasches. When I try do same on JMenu method getComponentCount() returns 0, so I can't get menu items (JMenuItem )to resize icon.
Question is how can I get menu items (JMenuItem) from JMenu, created automaticly from actions?