In this tutorials will teach how to create the main menu using java by code with out drag and drop.
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.MenuBar;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import java.awt.event.*;
public class Main extends Frame implements ActionListener {
public Main()
{
super("Menu");
Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
setSize(screensize);
setBackground(Color.black);
setLayout(null);
setResizable(false);
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu maintenance = new Menu("Maintenance");
mb.add(maintenance);
MenuItem add1 = new MenuItem("Employee");
maintenance.add(add1);
add1.addActionListener(this);
MenuItem edit1 = new MenuItem("Ammendment");
maintenance.add(edit1);
edit1.addActionListener(this);
MenuItem del1 = new MenuItem("Deletion");
maintenance.add(del1);
del1.addActionListener(this);
MenuItem inq1 = new MenuItem("Inquire");
maintenance.add(inq1);
inq1.addActionListener(this);
MenuItem exit = new MenuItem("Exit");
maintenance.add(exit);
exit.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
String s= e.getActionCommand();
if (s.equals("Employee"))
{
Empl A1= new Empl();
A1.show();
}
else if (s.equals("Exit"))
{
System.exit(0);
}
}
public static void main(String args[])
{
Main mm = new Main();
mm.show();
}
}
What Is the Tesla Pi Phone? Imagine if Tesla, the company that makes famous…
Inventory Management POS systems are now an essential part of modern businesses such as bookshops,…
If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…
GitHub is a powerful tool used by teams and developers around the globe. This guide is…
It's like having a super-smart buddy that is always there to help you write stories,…
The UK is known for its rich history, diverse culture, and most of all its…