Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import javax.swing.JFrame;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- public class Main {
- public static void main(String args[]) {
- Main a = new Main();
- a.Run();
- }
- private void Run() {
- JFrame frame = new JFrame("Name");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
- frame.setVisible(true);
- JMenuBar menuBar;
- JMenu fileMenu;
- JMenuItem fileMenuExit;
- menuBar = new JMenuBar();
- fileMenu = new JMenu("File");
- fileMenu.setMnemonic(KeyEvent.VK_F);
- menuBar.add(fileMenu);
- fileMenuExit = new JMenuItem("Exit");
- fileMenuExit.setActionCommand("menu-file-exit");
- fileMenuExit.addActionListener(new AL());
- fileMenu.add(fileMenuExit);
- frame.setJMenuBar(menuBar);
- }
- private class AL implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- if ("menu-file-exit".equals(e.getActionCommand())) {
- // prompt about exiting
- // if (!saved)
- System.exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement