Java Reference
In-Depth Information
Table 6-5. JMenu Properties (Continued)
Property Name
Data Type
Access
menuListeners
MenuListener[ ]
Read-only
model
ButtonModel
Write-only bound
popupMenu
JPopupMenu
Read-only
popupMenuVisible
boolean
Read-write
selected
boolean
Read-write
subElements
MenuElement[ ]
Read-only
tearOff
boolean
Read-only
topLevelMenu
boolean
Read-only
UIClassID
String
Read-only
Tip Keep in mind that many property methods are inherited and that the parent class might offer a getter
method where the current class defines only a new setter method, or vice versa.
The delay property represents the value for the time that elapses between selection
of a JMenu and posting of the JPopupMenu . By default, this value is zero, meaning that the
submenu will appear immediately. Trying to set the value to a negative setting will throw
an IllegalArgumentException .
Caution Since there is no support for tear-off menus, if you try to access the tearOff property, an error
will be thrown.
Selecting Menu Components
Normally, you don't need to listen for the selection of JMenu components. You listen for only
selection of individual JMenuItem components. Nevertheless, you may be interested in the
different ways that ChangeEvent works with a JMenu as compared with a JMenuItem . In addition,
a MenuEvent can notify you whenever a menu is posted or canceled.
 
Search WWH ::




Custom Search