Menu Building in NetBeans

30 downloads 306 Views 67KB Size Report
ECCS 166 - Programming 3 – Spring 2010. Dr. Estell. Creating Menus Using NetBeans. It is relatively easy to create a menu using NetBeans. First, go through  ...
ECCS 166 - Programming 3 – Spring 2010 Dr. Estell Creating Menus Using NetBeans It is relatively easy to create a menu using NetBeans. First, go through the process of setting up your GUI application as previously taught. Next, go into the Palette and add a JMenu to your GUI design:

The JMenuBar icon has the word "File" on it

You'll then have a menu bar at the top of the GUI with an initial JMenu already placed within the JMenuBar:

You can right-click within the selected area to change the text or to add components to this particular menu:

To add an additional JMenu to the JMenuBar, select the menu bar, then right-click to add:

When adding components to a menu, it is usually easier to use the Inspector to work with the components, rearrange the ordering if necessary, and to add event handlers:

Go into the properties for each menu item to assign mnemonics and accelerators. For mnemonics, just type the letter to be used:

Enter mnemonic character here

For accelerators, a dialog box will appear asking you to select a virtual key and combination of CTRL, ALT, and SHIFT key modifiers – the corresponding key stroke is then shown.

The keyboard shortcuts will now be displayed in the menu as shown below: