Java Reference
In-Depth Information
component is set to a menu on the menu bar, the menu components appear in a pop-up menu
within a window.
Caution The helpMenu property, although available with a set-and-get method, is unsupported in the
Swing releases through 5.0. Calling either accessor method will throw an error. With some future release of
Swing, the helpMenu property will likely make a specific JMenu the designated help menu. Exactly what
happens when a menu is flagged as the help menu is specific to the installed look and feel. What tends to
happen is that the menu becomes the last, or rightmost, menu.
Table 6-1. JMenuBar Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
borderPainted
boolean
Read-write
component
Component
Read-only
helpMenu
JMenu
Read-write
margin
Insets
Read-write
menuCount
int
Read-only
selected
boolean / Component
Read-write
selectionModel
SingleSelectionModel
Read-write
subElements
MenuElement[ ]
Read-only
UI
MenuBarUI
Read-write
UIClassID
String
Read-only
Note The selected property of JMenuBar is nonstandard. The getter method returns a boolean to
indicate if a menu component is selected on the menu bar. The setter method accepts a Component argument
to select a component on the menu bar.
Customizing a JMenuBar Look and Feel
Each predefined Swing look and feel provides a different appearance and set of default UIResource
values for the JMenuBar and each of the menu components. Figure 6-3 shows the appearance
of all these menu components for the preinstalled set of look and feel types: Motif, Windows,
and Ocean.
 
Search WWH ::




Custom Search