CRY-D / TextComponentPopUpBuilder

# TextComponentPopUpBuilder 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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TextComponentPopUpBuilder

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.

Usage

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

Example

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();
}

dependencies:

libs in the dist directory

Screenshots

Screenshot from 2023-09-19 16-13-42 Screenshot from 2023-09-19 16-13-57 Screenshot from 2023-09-19 16-14-04

Screenshot from 2023-09-19 16-15-46 Screenshot from 2023-09-19 16-15-58 Screenshot from 2023-09-19 16-16-32 Screenshot from 2023-09-19 16-15-32

About

# TextComponentPopUpBuilder 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.


Languages

Language:Java 100.0%