CODING:
import javax.swing.*;import java.awt.*;
import java.awt.event.*;
class myjframe1 extends JFrame implements ActionListener
{
JMenuBar menuBar = new JMenuBar();
JMenu firstmenu = new JMenu();
JMenuItem exit = new JMenuItem();
public myjframe1()
{
super();
setTitle("Menu Bar Example");
setSize(300, 200);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(menuBar);
menuBar.add(firstmenu);
firstmenu.setText("First Menu");
firstmenu.add(exit);
exit.setText(" Exit ");
exit.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == exit)
dispose();
}
}
class men
{
public static void main(String args[])
{
myjframe1 x= new myjframe1();
}
}
No comments:
Post a Comment