Class SJPopupMenu
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.contextmenu.ContextMenuBase<com.vaadin.flow.component.contextmenu.ContextMenu, com.vaadin.flow.component.contextmenu.MenuItem, com.vaadin.flow.component.contextmenu.SubMenu>
com.vaadin.flow.component.contextmenu.ContextMenu
com.vaadin.swingbridge.surrogates.SJPopupMenu
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.contextmenu.HasMenuItems, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, ComponentMixin, ContainerMixin, JComponentMixin, Serializable
public class SJPopupMenu
extends com.vaadin.flow.component.contextmenu.ContextMenu
implements JComponentMixin
Surrogate for
JPopupMenu (SD_sjpopupmenu). Extends Vaadin
ContextMenu directly and reproduces the Swing popup-menu surface
via the same tree-rebuild engine SJMenuBar uses — MenuBar,
ContextMenu, and SubMenu all implement Vaadin's
HasMenuItems, so the MenuTreeBuilder walk is shared above
the peer type.
Asymmetric split (same as SD_sjmenubar)
The menu-item family (JMenuItem / JMenu /
JCheckBoxMenuItem / JRadioButtonMenuItem / JSeparator)
stays emulator-only — no per-item surrogate classes — for the identical
R_vaadin_first reason SD_sjmenubar declined them: Vaadin MenuItem's ctor needs internal
collaborators. Pure-surrogate users compose with the inherited
ContextMenu.addItem(String, com.vaadin.flow.component.ComponentEventListener)
directly; the emulator-side :emulators.swing.JPopupMenu pushes a
MenuNode snapshot via rebuildFromTree(List).
Attaching to a component
On the surrogate layer, attach via the inheritedContextMenuBase.setTarget(com.vaadin.flow.component.Component) — that's
what the Swing-flavoured JComponentMixin.setComponentPopupMenu(SJPopupMenu)
helper (SD_sjpopupmenu) calls underneath. ContextMenu's default open trigger
is right-click / long-press, which matches Swing's right-click context menu.
Top-level separators render
UnlikeSJMenuBar (whose MenuBar peer has no top-level
addSeparator), ContextMenu supports separators at the root,
so the shared builder's top-level separator callback maps straight to
ContextMenuBase.addSeparator().
Accelerators
Per-itemKeyStroke accelerators install as UI-scoped
shortcuts via MenuTreeBuilder.installAccelerators(UI, Component, Map, Map), torn down on
every rebuild — same machinery as SJMenuBar.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
com.vaadin.flow.component.contextmenu.ContextMenuBase.OpenedChangeEvent<TComponent>Nested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
Fields inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
EVENT_DETAILFields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvenience accessor for tests + diagnostics — the most recently pushedMenuNodesnapshot (immutable copy).JDK matches"PopupMenuUI".protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) Clears the VaadinMenuItemtree.voidrebuildFromTree(List<MenuNode> tree) Push a fresh JDK menu-tree snapshot through to the VaadinContextMenu.Methods inherited from class com.vaadin.flow.component.contextmenu.ContextMenu
addItem, addItem, createMenuManager, getPosition, setPositionMethods inherited from class com.vaadin.flow.component.contextmenu.ContextMenuBase
addComponent, addComponent, addComponentAsFirst, addComponentAtIndex, addItem, addItem, addItem, addItem, addOpenedChangeListener, addSeparator, close, getChildren, getItems, getMenuManager, getTarget, isOpened, isOpenOnClick, onBeforeOpenMenu, remove, removeAll, setOpenOnClick, setTargetMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, updateUI
-
Constructor Details
-
SJPopupMenu
public SJPopupMenu()
-
-
Method Details
-
rebuildFromTree
Push a fresh JDK menu-tree snapshot through to the VaadinContextMenu. A snapshot that changes only checked states, handlers or accelerators updates the existing items (MenuTreeBuilder.patchInPlace(List, List, List)); anything else tears the tree down and rebuilds it. Top-level separators render viaContextMenuBase.addSeparator().The
preventRebuildre-entrancy guard short-circuits recursive calls.null/ empty tree fully clears the menu. -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) Clears the VaadinMenuItemtree. AContextMenuroot separator is an<hr>that doesn't appear inContextMenuBase.getItems(), so the recovery walk skips separators without stepping the peer index — the same alignmentMenuTreeBuilder.recoverLeafMap(List, List, Map)relies on.- Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
getCurrentTree
-
getUIClassID
JDK matches"PopupMenuUI".- Specified by:
getUIClassIDin interfaceJComponentMixin
-