C
- the context-menu typeI
- the menu-item typeS
- the sub menu typepublic abstract class SubMenuBase<C extends ContextMenuBase<C,I,S>,I extends MenuItemBase<C,I,S>,S extends SubMenuBase<C,I,S>> extends Object implements Serializable
ContextMenuBase
extensions. Classes
extending this should provide API for adding items and handling events
related to them. For basic example, see SubMenu
.Constructor and Description |
---|
SubMenuBase(I parentMenuItem) |
Modifier and Type | Method and Description |
---|---|
void |
add(Component... components)
Adds the given components into the sub menu overlay.
|
void |
addComponentAtIndex(int index,
Component component)
Adds the given component into the sub menu overlay at the given index.
|
I |
addItem(Component component)
Adds a new item component with the given component to the sub menu
overlay.
|
I |
addItem(String text)
Adds a new item component with the given text content to the sub menu
overlay.
|
protected abstract MenuManager<C,I,S> |
createMenuManager()
Creates a (sub) menu manager instance which contains logic to control the
(sub) menu content.
|
Stream<Component> |
getChildren()
Gets the child components of this sub menu.
|
List<I> |
getItems()
Gets the items added to this sub menu (the children of this component
that are instances of
MenuItem ). |
protected MenuManager<C,I,S> |
getMenuManager()
Gets a (sub) menu manager.
|
I |
getParentMenuItem()
Gets the menu item component that opens this sub menu overlay.
|
void |
remove(Component... components)
Removes the given components from the sub menu overlay.
|
void |
removeAll()
Removes all components inside the sub menu overlay.
|
public SubMenuBase(I parentMenuItem)
public I addItem(String text)
This is a convenience method for the use case where you have a list of
highlightable MenuItem
s inside the overlay. If you want to
configure the contents of the overlay without wrapping them inside
MenuItem
s, or if you just want to add some non-highlightable
components between the items, use the add(Component...)
method.
text
- the text content for the created menu itemadd(Component...)
public I addItem(Component component)
This is a convenience method for the use case where you have a list of
highlightable MenuItem
s inside the overlay. If you want to
configure the contents of the overlay without wrapping them inside
MenuItem
s, or if you just want to add some non-highlightable
components between the items, use the add(Component...)
method.
component
- the component to add to the created menu itemadd(Component...)
public void add(Component... components)
For the common use case of having a list of high-lightable items inside
the overlay, you can use the addItem(String)
convenience methods
instead.
The added elements will be inserted into an overlay that is attached into
the <body>
.
components
- the components to addHasMenuItems.addItem(String, ComponentEventListener)
,
HasMenuItems.addItem(Component, ComponentEventListener)
public void remove(Component... components)
components
- the components to removeadd(Component...)
public void removeAll()
add(Component...)
public void addComponentAtIndex(int index, Component component)
The added elements will be inserted into an overlay that is attached into
the <body>
.
index
- the index, where the component will be addedcomponent
- the component to addadd(Component...)
public Stream<Component> getChildren()
add(Component...)
and the MenuItem
components
created with addItem(String)
and its overload methods. This
doesn't include the components added to the main context menu or any
other sub menus it may have.public List<I> getItems()
MenuItem
).MenuItem
components in this sub menuaddItem(String)
,
getChildren()
public I getParentMenuItem()
protected MenuManager<C,I,S> getMenuManager()
protected abstract MenuManager<C,I,S> createMenuManager()
Copyright © 2025. All rights reserved.