Java

How to create the Main menu using Java

In this tutorials will teach how to create the main menu using java by code with out drag and drop.

This is the code which we use to create the Main Menu by code

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();
}

}

 

 

 

 

admin

Recent Posts

Registration with image upload Java Jdbc(Download Source code)

Introduction In this section, we will guide you step by step in the development of an image upload registration system in Java using MySQL and JDBC. In the application, users register…

3 weeks ago

Touchable shop Pos system using Java

The Touchable Shop POS (Point of Sale) system is a sophisticated software solution developed using…

1 month ago

Build Your First Responsive Login Form Using HTML and CSS FlexBox

Creating a responsive login form is a crucial skill for any web developer. In this…

1 month ago

Build Crud API with Laravel 12

In this tutorial will teach  Laravel 12 CRUD API  by step. Laravel  10 CRUD Application …

2 months ago

laravel 12 image upload tutorial

In this lesson we talk about laravel 12 image uploading and display the image step…

2 months ago

Laravel 12 CRUD Application

In this tutorial will teach Laravel 12 CRUD Application step by step. Laravel  12 CRUD…

2 months ago