How to Create Java Menu in swing

code Description:

//Create Menu Bar first (first line) and create Menu item Master(3rd line) and add menu item to menu //bar(4th.line).when user clicks on Student Add item add under Master Menu item, Student Add form

//opens up for record addition, here two parameters are passed from login form to Student Add form

//and Displayed.  

JMenuBar menuBar = new JMenuBar();

setJMenuBar(menuBar);

JMenu mnMaster = new JMenu("Master");

menuBar.add(mnMaster);

JMenuItem mntmStudent = new JMenuItem("Student Add");

mntmStudent.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

String Sch_name = school_name.getText();

String School_year = Sch_year.getText();

new st_master(Sch_name,School_year).setVisible(true);

}

});

mnMaster.add(mntmStudent);

Below is Menu attached and Student Add item is highlighted ...





Comments