Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.samkough.main;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class Win extends JFrame
- {
- private static final int WIDTH = 600;
- private static final int HEIGHT = 600;
- JMenuBar mb1;
- JMenu m1;
- JMenuItem mi1;
- public static void main(String args[])
- {
- Win frame = new Win();
- frame.setVisible(true);
- frame.setSize(WIDTH, HEIGHT);
- frame.setTitle("Menu Bar");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- }
- public Win()
- {
- setLayout(new FlowLayout());
- mb1 = new JMenuBar();
- setJMenuBar(mb1);
- m1 = new JMenu("File");
- mb1.add(m1);
- mi1 = new JMenuItem("Exit");
- m1.add(mi1);
- event e = new event();
- mi1.addActionListener(e);
- }
- public class event implements ActionListener
- {
- public void actionPerformed(ActionEvent e)
- {
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment