Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class Main extends JFrame {
    static JMenuBar exampleMenuBar = new JMenuBar();
    static JMenu fileMenu = new JMenu("Help");
    static JMenuItem Exit = new JMenuItem("Exit");

    public static void main(String args[]) {
        new Main().setVisible(true);
    }

    public Main() {
        setSize(100, 100);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setJMenuBar(exampleMenuBar);
        exampleMenuBar.add(fileMenu);
        fileMenu.add(Exit);
        Exit.addActionListener(e -> System.exit(0));
    }
}