Record Class MenuNode
java.lang.Object
java.lang.Record
com.vaadin.swingbridge.surrogates.MenuNode
public record MenuNode(String text, com.vaadin.flow.component.Component icon, boolean enabled, boolean separator, boolean checkable, boolean checked, KeyStroke accelerator, Runnable onClick, List<MenuNode> children)
extends Record
Surrogate-internal descriptor consumed by
SJMenuBar.rebuildFromTree(List)
(SD_sjmenubar). The emulator-side :emulators.swing.JMenuBar walks its JDK
menu tree on every mutation, builds a List<MenuNode>, and pushes
it through the surrogate's tree-rebuild API. Pure-surrogate users never
see this type — they compose with Vaadin MenuBar.addItem directly
per [R_vaadin_first](../../CLAUDE.md).
Lives in com.vaadin.swingbridge.surrogates (not :emulators) per [SD_shelper_statics](decisions.md):
the descriptor is the surrogate's input, so it lives on the surrogate
side of the :emulators → :surrogates boundary.
Field semantics
text— the rendered label. Empty string for icon-only items.nullmatches JDK's icon-only ctor convention.icon— pre-converted VaadinComponent(typically acom.vaadin.flow.component.html.ImagefromIcons.imageIconToVaadinImage(ImageIcon)). The emulator runs the conversion before populating the descriptor; the surrogate just passes the resulting Component to Vaadin'sMenuBar.addItem(Component, listener)overload.enabled— drives VaadinMenuItem.setEnabled.separator— whentrue, the rebuild walk emitssubMenu.addSeparator()(or drops + WARNs at the top level per SD_sjmenubar's accepted gap). All other fields ignored.checkable— drives VaadinMenuItem.setCheckable.checked— drives VaadinMenuItem.setCheckedwhencheckableistrue.accelerator— JDKKeyStroke. The surrogate's rebuild path translates viaKeyConvert.toVaadinKeyBinding(KeyStroke)and installs a UI-scopedShortcuts.addShortcutListener. Unmappable keystrokes log + skip browser install but the emulator-side field round-trip survives.onClick— fires the JDK ActionEvent on the emulator side. The surrogate wraps invocation inSHelper.callSwing(Runnable)(R_callswing_envelope funnel for blocking-dialog work).nullmeans "non-clickable" — used for top-levelJMenucontainers whose click opens a submenu (Vaadin handles that natively, no handler needed).children— nested submenu items. Empty for leafJMenuItems; populated forJMenus.
Immutable record — every rebuild builds fresh nodes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theacceleratorrecord component.booleanReturns the value of thecheckablerecord component.booleanchecked()Returns the value of thecheckedrecord component.children()Returns the value of thechildrenrecord component.booleanenabled()Returns the value of theenabledrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.com.vaadin.flow.component.Componenticon()Returns the value of theiconrecord component.static MenuNodeConvenience: a leafJMenuItem-shape node with text + enabled + onClick.static MenuNodeConvenience: aJMenu-shape node with text + enabled + children.static MenuNodeConvenience: a separator node — only the separator flag is meaningful.onClick()Returns the value of theonClickrecord component.booleanReturns the value of theseparatorrecord component.text()Returns the value of thetextrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MenuNode
public MenuNode(String text, com.vaadin.flow.component.Component icon, boolean enabled, boolean separator, boolean checkable, boolean checked, KeyStroke accelerator, Runnable onClick, List<MenuNode> children) Creates an instance of aMenuNoderecord class.- Parameters:
text- the value for thetextrecord componenticon- the value for theiconrecord componentenabled- the value for theenabledrecord componentseparator- the value for theseparatorrecord componentcheckable- the value for thecheckablerecord componentchecked- the value for thecheckedrecord componentaccelerator- the value for theacceleratorrecord componentonClick- the value for theonClickrecord componentchildren- the value for thechildrenrecord component
-
-
Method Details
-
ofSeparator
Convenience: a separator node — only the separator flag is meaningful. -
ofItem
-
ofMenu
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
icon
public com.vaadin.flow.component.Component icon()Returns the value of theiconrecord component.- Returns:
- the value of the
iconrecord component
-
enabled
public boolean enabled()Returns the value of theenabledrecord component.- Returns:
- the value of the
enabledrecord component
-
separator
public boolean separator()Returns the value of theseparatorrecord component.- Returns:
- the value of the
separatorrecord component
-
checkable
public boolean checkable()Returns the value of thecheckablerecord component.- Returns:
- the value of the
checkablerecord component
-
checked
public boolean checked()Returns the value of thecheckedrecord component.- Returns:
- the value of the
checkedrecord component
-
accelerator
Returns the value of theacceleratorrecord component.- Returns:
- the value of the
acceleratorrecord component
-
onClick
Returns the value of theonClickrecord component.- Returns:
- the value of the
onClickrecord component
-
children
-