Question
Working with the code: import javax.swing.*; import java.awt.event.*; publicclass JavaMenus extends JFrame{ public JavaMenus() { super (Java Menu Example); JMenu file = new JMenu(File); file.setMnemonic('F');
Working with the code:
import javax.swing.*; import java.awt.event.*;
publicclassJavaMenusextends JFrame{
public JavaMenus() { super("Java Menu Example");
JMenu file = new JMenu("File"); file.setMnemonic('F'); JMenuItem ItemNew = new JMenuItem("New"); ItemNew.setMnemonic('N'); file.add(ItemNew); JMenuItem ItemOpen = new JMenuItem("Open"); ItemOpen.setMnemonic('O'); file.add(ItemOpen); JMenuItem ItemExit = new JMenuItem("Exit"); ItemExit.setMnemonic('x'); file.add(ItemExit);
final JLabel label1 = new JLabel(" Welcome"); add(label1); this.setSize(100, 100); setVisible(true);
ItemNew.addActionListener( new ActionListener(){ publicvoid actionPerformed(ActionEvent e) { label1.setText(" New"); JOptionPane.showMessageDialog(null, "New was Clicked", "Result", JOptionPane.PLAIN_MESSAGE); } } ); ItemOpen.addActionListener( new ActionListener(){ publicvoid actionPerformed(ActionEvent e) { label1.setText(" Open"); JOptionPane.showMessageDialog(null, "Open was Clicked", "Result", JOptionPane.PLAIN_MESSAGE); } } );
Modify the program again: program will include a new second column of menu items. To do this alter the menubar such that it will contain these items.
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started