简体   繁体   English

在Mac上的NetBeans中使用AWT构建基本的记事本

[英]Building a basic Notepad using AWT in NetBeans on Mac

This code runs fine on Windows, but not on my Macbook Air. 该代码可以在Windows上正常运行,但不能在我的Macbook Air上运行。 Why? 为什么? No Menu bar is visible; 没有菜单栏可见; only the text area is visible in the output. 在输出中只有文本区域可见。

图片

import java.awt.*;

public class Notepad extends Frame {
    public Notepad()
    {
        setTitle("Untitled-Notepad");
        TextArea t1 = new TextArea(50,80);

        MenuBar mb = new MenuBar();
        Menu file = new Menu("File");
        MenuItem n1 = new MenuItem("New");

        file.add(n1);
        mb.add(file);
        setMenuBar(mb);

        add(t1);

        setSize(350,450);
        setVisible(true);
        setLayout(null);
    }

    public static void main(String[] args) {
        Notepad n = new Notepad();
    }
}

It appears in the "System Menu Bar". 它出现在“系统菜单栏”中。

系统工具栏

See, above the title bar, next to "NotePad". 请参阅标题栏上方“记事本”旁边。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM