Java Reference
In-Depth Information
JPopupMenu Properties
The 16 properties of JPopupMenu are listed in Table 6-9. Many more properties are also inherited
through JComponent , Container , and Component .
Table 6-9. JPopupMenu Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
borderPainted
boolean
Read-write
component
Component
Read-only
invoker
Component
Read-only
label
String
Read-write bound
lightWeightPopupEnabled
boolean
Read-write
margin
Insets
Read-only
menuKeyListeners
MenuKeyListener[ ]
Read-only
popupMenuListeners
PopupMenuListener[ ]
Read-only
popupSize
Dimension
Write-only
selected
Component
Write-only
selectionModel
SingleSelectionModel
Read-write
subElements
MenuElement[ ]
Read-only
UI
PopupMenuUI
Read-write bound
UIClassID
String
Read-only
visible
boolean
Read-write
The most interesting property of JPopupMenu is lightWeightPopupEnabled . Normally, the
JPopupMenu tries to avoid creating new heavyweight components for displaying its menu items.
Instead, the pop-up menu uses a JPanel when the JPopupMenu can be displayed completely
within the outermost window boundaries. Otherwise, if the menu items don't fit, the JPopupMenu
uses a JWindow . If, however, you're mixing lightweight and heavyweight components on different
window layers, displaying the pop-up within a JPanel might not work, because a heavyweight
component displayed in the layer of the menu will appear in front of the JPanel . To correct this
behavior, the pop-up menu can use a Panel for displaying the menu choices. By default, the
JPopupMenu never uses a Panel .
 
Search WWH ::




Custom Search