0

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?

PAT
  • 11
  • 4
  • 2
    post an SSCCE/MCVE, there you can to use the built_in Icons by using UIManager.getIcon("OptionPane.errorIcon" / "informationIcon" / "warningIcon" / "questionIcon"); – mKorbel Jul 09 '14 at 10:18
  • 1
    As shown [here](http://stackoverflow.com/a/12228640/230513). – trashgod Jul 09 '14 at 11:07

0 Answers0