Search code examples
javanetbeansawtmenubarnotepad

Building a basic Notepad using AWT in NetBeans on Mac


This code runs fine on Windows, but not on my Macbook Air. Why? No Menu bar is visible; only the text area is visible in the output.

image

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();
    }
}

Solution

  • It appears in the "System Menu Bar".

    System ToolBar

    See, above the title bar, next to "NotePad".