I want to create a very simple JMenuBar with 2 clickable JMenuItems with the following code:
JFrame window = new JFrame();
JMenuBar bar = new JMenuBar();
JMenuItem open = new JMenuItem("Open"), reload = new JMenuItem("Reload");
bar.add(open);
bar.add(reload);
window.setJMenuBar(bar);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
However, the two Items have a huge space in between them and I have no idea where this is coming from:
I would expect the "Reload" item to be right next to the "Open" item.
This is the very first part of the code that runs (with a breakpoint immediately after), so nothing else can interfere with it.
Is there something 'obvious' I am missing?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…