[英]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();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.