JAVA Hello I am trying to add a menu to my Java code if some

JAVA

Hello I am trying to add a menu to my Java code if someone can help me I would really appreacite it thank you.

I found a java menu code but I dont know how to incorporate it to my code this is the java menu code that i found.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

and this is the code that I created where I want to add the menu to

Thank you in advance

Solution

At TravelExpenses class please add the following code which incorporates the menu:

JFrame frame = new JFrame(\"MenuSample Example\");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new MenuExp();

// File Menu, F - Mnemonic
JMenu fileMenu = new JMenu(\"File\");
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);

// File->New, N - Mnemonic
JMenuItem newMenuItem = new JMenuItem(\"New\", KeyEvent.VK_N);
fileMenu.add(newMenuItem);

frame.setJMenuBar(menuBar);
frame.setSize(350, 250);
frame.setVisible(true);

JAVA Hello I am trying to add a menu to my Java code if someone can help me I would really appreacite it thank you. I found a java menu code but I dont know how

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site