开发者

JMenubar error?

开发者 https://www.devze.com 2023-02-21 04:55 出处:网络
import javax.swing.*; class Main { public static void main(String[] args) { JFrame frame = new JFrame();
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");

JMenubar error?

0

精彩评论

暂无评论...
验证码 换一张
取 消