1

Take a look at this picture:

enter image description here

It seems my green arrow button keeps making the JMenuBar taller than it should be, notice the space above and below the rest of the buttons. How do I stop it from doing this? I've tried making the JButton border/padding as small as possible, here is my code:

JButton runFlow;
runFlow = new JButton(IconHandler.getIcon(IconHandler.RUN_ICON));
runFlow.setOpaque(false);
runFlow.setContentAreaFilled(false);
runFlow.setBorder(null);
runFlow.setBorderPainted(false);
runFlow.setMargin(new java.awt.Insets(0,0,0,0));

Is it something to do with the menu bar format?

Madhan
  • 5,750
  • 4
  • 28
  • 61
danglingPointer
  • 882
  • 8
  • 32
  • 1
    *"JButton inside JMenuBar isn't tight-fitting?"* Buttons go better in a `JToolBar`. But for 'snug fit' try `GridLayout` or `GridBagLayout` in a `JPanel`.. – Andrew Thompson Jul 30 '15 at 01:09
  • 1
    I agree with JButtons being better held in a JToolBar. In addtion, check your RUN_ICON. Does the picture contain further (transparent) pixels above and below the arrow we are seeing? – Carsten Jul 30 '15 at 01:20
  • AFAIK there is BoxLayout, but hasn't something to do with Dimension from Icon – mKorbel Jul 30 '15 at 06:10
  • 1
    change the icon size to a smaller one like 16 x 16 – Madhan Jul 30 '15 at 06:39

0 Answers0