So I've been trying to give my Java Swing application a native Windows look using JGoodies-Looks' 2.7.0 Windows L&F, but stumbled upon a problem while trying to create a JMenuBar, as it looks weird. What am I doing wrong?
This is how a JMenu looks in jgoodies-looks demo:
And this is how it looks in my demo app:
Please Note: the first JMenuItem is howevered
Demo code:
import com.jgoodies.looks.windows.WindowsLookAndFeel;
import javax.swing.*;
public class TestForm extends JFrame {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
} catch (Exception e) {
System.out.println("Can't change L&F: " + e);
}
SwingUtilities.invokeLater(TestForm::new);
}
public TestForm(){
this.setBounds(200, 200, 500, 500);
this.setTitle("Test");
this.setJMenuBar(constructMenuBar());
this.setVisible(true);
}
private JMenuBar constructMenuBar(){
JMenuBar menuBar = new JMenuBar();
menuBar.add(constructEditMenu());
return menuBar;
}
private JMenu constructEditMenu() {
JMenu menu = new JMenu("Edit");
menu.add(createItem("Copy"));
menu.add(new JSeparator());
menu.add(createItem("Paste"));
return menu;
}
private JMenuItem createItem(String title){
return new JMenuItem(title);
}
}