Menubar in Applet

import javax.swing.*;
import java.awt.event.*;

public class MenuBarWithApplet extends JApplet implements ActionListener {
	JMenuBar bar;
	JMenu file, edit;
	JMenuItem new1, save, close;

	@Override
	public void init() {
		bar = new JMenuBar();
		file = new JMenu("file");
		edit = new JMenu("Edit");
		new1 = new JMenuItem("new");
		save = new JMenuItem("save");
		close = new JMenuItem("close");
		setJMenuBar(bar);
		bar.add(file);
		bar.add(edit);
		file.add(new1);
		file.add(save);
		file.add(close);
		close.addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent evt) {
		if (evt.getSource() == close) {
			System.exit(0);
		}
	}

}

Download

Applet in Swing

Simple Applet
Applet life cycle
Parameter in Applet
Manu bar in Applet


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code