Hi I’ve got a little Swing Application with a Menu.
First two attributes containing the menues text are created, then the lookandfeel is set to windows and at last the menues are filled.
Here is the source code:
private JMenu[] Menue={new JMenu("File")};
private JMenuItem[][] MenuItemsString ={{new JMenuItem("Import"),new JMenuItem("Export")}};
...
public window(){
super ("Q3MeshConverter");
plate = new JPanel(new BorderLayout());
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");// set Windows lookandfeel
}
catch(Exception x){
}
menuBar = new JMenuBar();
...
setJMenuBar(menuBar);
JMenu[] Menu =Menue;
JMenuItem[][] MenuItems =MenuItemsString;
for(int m=0;m<Menu.length;m++){// loop trough the Menu(es)
menuBar.add(Menu[m]);
for(int mi=0;mi<MenuItems[m].length;mi++){// loop through the MenuItems
Menu[m].add(MenuItems[m][mi]);
MenuItems[m][mi].addActionListener(this);
}
}
...
setContentPane (plate);
}
And that’s the ugly output:

Why does it looks like this?
Set the look and feel in your
mainmethod: