import javax.swing.*;
class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu();
JMenuItem item1 = new JMenuItem("aaaa");
fil开发者_如何转开发eMenu.add(item1);
menuBar.add(fileMenu);
frame.setJMenuBar(menuBar);
frame.setVisible(true);
}
}
Pretty simple code. It should show a JMenuBar with a JMenuItem labelled "aaaa" but nothing shows as you can see in the picture below.
I'm using Java Update 24 with JDK 24 on Windows 7 64bit
http://img11.imageshack.us/img11/3457/31137617.png
It is there, but you can't see it because you didn't give the JfileMenu a name.
JMenu fileMenu = new JMenu("File");
精彩评论