When you are setting up the menu bar, tool bars, or pop-up menus in your Lucy application, you may wish to change the UI component that goes with a certain tool bar item, or maybe you want to adjust the behavior of a UI component.

For instance, you want to replace a button in a tool bar with a custom button or another GUI widget.

Figure 1. Turning a search button into a search bar

In another use case, you want to be able to delete layers by dragging them on to an existing Delete button in the tool bar. To do so, you need to modify the component so that it has a drop listener.

In both cases, you can use the Lucy action bar API to customize the tool bar component.

The ILcyActionBar API has no method to insert a component, only to insert ILcdAction and ILcyActiveSettable instances.

Detailed steps

  1. Create an ILcyCustomizableRepresentationAction (for actions) or an ILcyCustomizableRepresentationActiveSettable (for togglable actions), and insert it in the tool bar like any other action.

  2. Return the component from the customizeRepresentation method

    Program: Use a custom representation when the action is inserted into an ILcyToolBar, and use the default representation otherwise. (from samples/lucy/tableview/FindInTableAction)
    public Component customizeRepresentation(Component aDefaultComponent,
                                             ILcdAction aWrapperAction,
                                             ILcyActionBar aActionBar) {
      //custom representation for tool bars
      if (aActionBar instanceof ILcyToolBar) {
        return TLcyAlwaysFitJToolBar.createToolBarPanel(fFindBar);
      //use the default representation for all other action bars
      return aDefaultComponent;

More information about setting up a customizable representation action

The ILcyCustomizableRepresentationAction and ILcyCustomizableRepresentationActiveSettable interfaces allow you to adjust the GUI components that represent an action or active settable. They are extensions of ILcdAction and ILcyActiveSettable respectively, and can be inserted into an action bar in the same way as any other action or active settable.

Make sure that your ILcyActionBar implementation supports these interfaces. The TLcyToolBar class supports them by default, and will call the customizeRepresentation method to check if an alternative action representation needs to be applied.

The FindInTableAction example is taken from the Lucy editable table sample. It demonstrates a table view below the map in the Lucy application. The table offers an overview of the metadata associated with the objects on the map. There is a text box right above the table that serves as a search field, and allows users to look up a search term in the table data.


The FindInTableAction models that table search functionality in Lucy. When the table search action appears in a toolbar, users should be able to enter their query directly into the toolbar by means of a text field UI widget. To set up such a find bar in this program, we define a custom representation of the search FindInTableAction for the tool bar case, and swap the default representation for the find bar.

If the find bar appears in a tool bar type of action bar, we add a search bar containing an input field and next/previous result buttons. In any other kind of Lucy action bar, we use the default UI component for search functionality.