Class Toolbar

All Implemented Interfaces:
Animatable<Toolbar>, CanDrop<Toolbar>, Draggable<Toolbar>, Scrollable<Toolbar>

public class Toolbar extends Component<Toolbar> implements Animatable<Toolbar>, Scrollable<Toolbar>, CanDrop<Toolbar>, Draggable<Toolbar>

Toolbar component

The toolbar component places components (by default, Buttons) on a bar. Please note that the Toolbar component is used for grouping the assigned components, it doesn't handle them, and isn't responsible for their color/operation.

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • Toolbar

      public Toolbar()
      Creates an empty Toolbar
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Toolbar

      public Toolbar(String id)
      Creates an empty Toolbar with specified ID
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
  • Method Details

    • setButtonType

      public Toolbar setButtonType(ButtonType buttonType)
      Sets the default button type for the toolbar buttons. This defaults to the DEFAULT type. The button type specified here will be used for buttons, that don't have their types set individually.
      Parameters:
      buttonType - The button type of the toolbar button. For the applicable types, see the ButtonType enum.
      Returns:
      The toolbar component
    • setButtonSize

      public Toolbar setButtonSize(ButtonSize buttonSize)
      Sets the default button size for the toolbar buttons. This defaults to the DEFAULT type. The button size specified here will be used for buttons, that don't have their sizes set individually.
      Parameters:
      buttonSize - The button size of the toolbar button. For the applicable sizes, see the ButtonSize enum.
      Returns:
      The toolbar component
    • addButton

      public Toolbar addButton(Button btn)
      Adds a button component to the toolbar.
      Parameters:
      btn - The button component
      Returns:
      The toolbar component
    • addButton

      public Toolbar addButton(DropDownButton btn)
      Adds a button component to the toolbar.
      Parameters:
      btn - The button component
      Returns:
      The toolbar component
    • addButtons

      public Toolbar addButtons(Component<?>... buttons)
      Adds multiple button components to the toolbar, in the order they are specified.
      Parameters:
      buttons - The button components
      Returns:
      The toolbar component
    • addButton

      public Toolbar addButton(Icon icon, String title, ClickEventHandler clickHandler)
      Adds a button component, with the specified icon, title and click handler, to the toolbar.
      Parameters:
      icon - The icon of the button. For the applicable icons, see the Icon enum. If specified as null, the button won't have an icon
      title - The title of the button. If specified as null, the button won't have any text on it
      clickHandler - The ClickEventHandler implementation.
      Returns:
      The toolbar component
    • addButton

      public Toolbar addButton(ButtonType buttonType, Icon icon, String title, ClickEventHandler clickHandler)
      Adds a button component, with the specified style, icon, title and click handler to the toolbar.
      Parameters:
      buttonType - The style of the toolbar button. For the applicable types, see the ButtonType enum. For the applicable sizes, see the ButtonSize enum. The specified style overwrites the default button size/type.
      icon - The icon of the button. For the applicable icons, see the Icon enum. If specified as null, the button won't have an icon
      title - The title of the button. If specified as null, the button won't have any text on it
      clickHandler - The ClickEventHandler implementation.
      Returns:
      The toolbar component
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Toolbar>
      Returns:
      If the componentwas drawn, true, otherwise false
    • setVisible

      public Toolbar setVisible(boolean visible)
      Sets the visibility of the component. If not visible, the component won't appear on the interface, but it will be drawn in the HTML DOM. The visibility can be set anytime through code. By default, the component is visible
      Overrides:
      setVisible in class Component<Toolbar>
      Parameters:
      visible - If true, the component is visible, if false, it is hidden
      Returns:
      The component