Java Swing TextComponentPopUpBuilder This is a Java Swing component that allows you to add a popup menu to a text component. It provides a fluent API to configure the popup menu and register the actions globally.
You can use the TextComponentPopUpBuilder like this:
new TextComponentPopUpBuilder(component)
.registerActionsGlobally(rootPane)
.setPadding(padding)
.setMenuType(menuType)
.build();
Here, component is the text component to which the popup menu is attached:
- rootPane is the root pane where the actions shortcuts will be registered globally (it can be null), 'getRootPane()'
- padding is the padding for the popup menu itels (optional) its array of integers
- and menuType is the type of the menu. could be:
MenuType.REGULAR, MenuType.MINIMUM , MenuType.MAXIMUM
Here is an example from the demo frame of how to use the TextComponentPopUpBuilder:
public NewJFrame() {
initComponents();
initTextComponet(regularText, MenuType.REGULAR);
initTextComponet(miniText, MenuType.MINIMUM);
initTextComponet(maxText, MenuType.MAXIMUM);
}
private void initTextComponet(JTextComponent component, MenuType menuType) {
new TextComponentPopUpBuilder(component)
.registerActionsGlobally(rootPane)
.setPadding(padding)
.setMenuType(menuType).build();
}
libs in the dist directory