Class Button

All Implemented Interfaces:
Control, Enableable, Focusable, HasAttribute, HasClassName, HasComputedStyle, HasControlText, HasDestroy, HasStyle, HasTooltip, HasVisibility, TabTraversable, TextAlignable

public final class Button extends AbstractDwcControl implements Focusable, TabTraversable, TextAlignable
A Push Button
  • Constructor Details

    • Button

      public Button()
    • Button

      public Button(String text)
      Parameterized button constructor, accepts a string as an argument which will be the initial text displayed on the button
      Parameters:
      text - String value for initial button text
  • Method Details

    • create

      protected void create(AbstractDwcjPanel p)
      Description copied from class: AbstractControl
      Create the object on a panel p. The preferred way of creating an object is using the Panel::add(Control) method, instead of this
      Overrides:
      create in class AbstractControl
      Parameters:
      p - the panel to add this control on
    • onClick

      public Button onClick(Consumer<ButtonClickEvent> callback)
      register an event callback for the click event
      Parameters:
      callback - A method to receive the click event
      Returns:
      the control itself
    • isDisableOnClick

      public Boolean isDisableOnClick()
      Accessor for whether or not the button is disabled.
      Returns:
      Boolean value
    • setDisableOnClick

      public Button setDisableOnClick(Boolean disable)
      Mutator for whether or not the button is disabled on click
      Parameters:
      disable - Boolean value
      Returns:
      Instance of the object to enable method chaining.
    • getVerticalAlignment

      public Button.TextVerticalAlignment getVerticalAlignment()
      Accessor for the vertical alignment of text within the button
      Returns:
      Enum value of text's vertical alignment
    • setVerticalAlignment

      public Button setVerticalAlignment(Button.TextVerticalAlignment alignment)
      Mutator for the vertical alignment of text within the button
      Parameters:
      Button - TextVerticalAlignment enum value
      Returns:
      The Button itself
    • setText

      public Button setText(String text)
      Description copied from interface: HasControlText
      set the text of the control Each control implementing this interface has a text property, which might be visible in different ways (caption, title, contents of edit) or sometimes not visible at all
      Specified by:
      setText in interface HasControlText
      Overrides:
      setText in class AbstractDwcControl
      Returns:
      the control itself
    • setVisible

      public Button setVisible(Boolean visible)
      Description copied from interface: HasVisibility
      Set whether the control is visible or invisible
      Specified by:
      setVisible in interface HasVisibility
      Overrides:
      setVisible in class AbstractDwcControl
      Returns:
      the control itself
    • setEnabled

      public Button setEnabled(Boolean enabled)
      Description copied from interface: Enableable
      Set whether the control is to be enabled
      Specified by:
      setEnabled in interface Enableable
      Overrides:
      setEnabled in class AbstractDwcControl
      Returns:
      the control itself
    • setTooltipText

      public Button setTooltipText(String text)
      Description copied from interface: HasTooltip
      Set the tooltip text of the control
      Specified by:
      setTooltipText in interface HasTooltip
      Overrides:
      setTooltipText in class AbstractDwcControl
      Returns:
      the control itself
    • setAttribute

      public Button setAttribute(String attribute, String value)
      Description copied from class: AbstractDwcControl
      set the value for an attribute in the control
      Specified by:
      setAttribute in interface HasAttribute
      Overrides:
      setAttribute in class AbstractDwcControl
      Parameters:
      attribute - the name of the attribute
      value - the value to be set
      Returns:
      the control itself
    • setId

      public Button setId(String elementId)
      Description copied from interface: Control
      Assigns the ID of a control
      Specified by:
      setId in interface Control
      Overrides:
      setId in class AbstractControl
      Parameters:
      elementId - Desired ID designation
      Returns:
      The control itself
    • setStyle

      public Button setStyle(String property, String value)
      Description copied from interface: HasStyle
      Assigns specified value to the specified CSS property
      Specified by:
      setStyle in interface HasStyle
      Overrides:
      setStyle in class AbstractDwcControl
      Parameters:
      property - The CSS property to be changed
      value - The value of the selected CSS property
      Returns:
      The control itself
    • addClassName

      public Button addClassName(String selector)
      Description copied from interface: HasClassName
      Adds a CSS class to the list of CSS classes for the control.
      Specified by:
      addClassName in interface HasClassName
      Overrides:
      addClassName in class AbstractDwcControl
      Returns:
      The control itself
    • removeClassName

      public Button removeClassName(String selector)
      Description copied from interface: HasClassName
      Removes a CSS class from the list of CSS classes for the control.
      Specified by:
      removeClassName in interface HasClassName
      Overrides:
      removeClassName in class AbstractDwcControl
      Returns:
      The control itself
    • getExpanse

      public Button.Expanse getExpanse()
      Accessor to return the button object's current expanse
      Returns:
      Expanse enum from the button class
    • setExpanse

      public Button setExpanse(Button.Expanse expanse)
      Mutator to change the expanse of a button that requires a specific button enum value
      Parameters:
      expanse - button expanse enum value
      Returns:
      The button object itself
    • getTheme

      public Button.Theme getTheme()
      Accessor to return the button object's current theme
      Returns:
      Expanse enum from the button class
    • setTheme

      public Button setTheme(Button.Theme theme)
      Mutator to change the theme of a button that requires a specific button enum value
      Parameters:
      theme - button theme enum value
      Returns:
      The button object itself
    • isFocusable

      public Boolean isFocusable()
      Description copied from interface: Focusable
      isFocusable returns a value indicating whether or not the user can focus the control. Note: A focused control is the control to which keyboard interaction is directed. Typically, the focused control is indicated visually, often via a dotted grey border. A control which is not focusable, therefore, cannot be manipulated via the keyboard. It is still possible to interact with a non-focusable control via the mouse.
      Specified by:
      isFocusable in interface Focusable
      Returns:
      True if object can be focused, False if not.
    • setFocusable

      public Button setFocusable(Boolean focusable)
      Description copied from interface: Focusable
      setFocusable sets whether a control can be focused. Note: A focused control is the control to which keyboard interaction is directed. Typically, the focused control is indicated visually, often via a dotted grey border. A control which is not focusable, therefore, cannot be manipulated via the keyboard. It is still possible to interact with a non-focusable control via the mouse. To disable all interaction, including the mouse, see setEnabled() and setReadOnly().
      Specified by:
      setFocusable in interface Focusable
      Parameters:
      focusable - Boolean True for allowing focusing, False to disable focus
      Returns:
      Object itself
    • isTabTraversable

      public Boolean isTabTraversable()
      Description copied from interface: TabTraversable
      Returns a boolean indicating whether or not the user can navigate to the control using the tab key.
      Specified by:
      isTabTraversable in interface TabTraversable
      Returns:
      True if user can navigate to control with Tab key, False if not
    • setTabTraversable

      public Button setTabTraversable(Boolean traversable)
      Description copied from interface: TabTraversable
      Sets whether or not the user can navigate to the control using the tab key.
      Specified by:
      setTabTraversable in interface TabTraversable
      Parameters:
      traversable - Boolean dictating tab traversal. True if control can be navigated to with Tab, False if not.
      Returns:
      The control itself
    • getTextAlignment

      public TextAlignable.Alignment getTextAlignment()
      Description copied from interface: TextAlignable
      Returns a value indicating the text's horizontal alignment.
      Specified by:
      getTextAlignment in interface TextAlignable
      Returns:
    • setTextAlignment

      public Button setTextAlignment(TextAlignable.Alignment alignment)
      Description copied from interface: TextAlignable
      Sets the horizontal alignment of the text within the control.
      Specified by:
      setTextAlignment in interface TextAlignable
      Parameters:
      alignment - Enum from list representing an internal BBj numeric constant
      Returns:
      The control itself
    • catchUp

      protected void catchUp() throws IllegalAccessException
      Description copied from class: AbstractDwcControl
      The catchUp method is used to replay attributes and settings that the API user might have added to a control before its creation. A control is not created before it's added to a panel. Anything that is added between instantiation of a control and its addition to a panel has to be recorded and replayed in this method
      Overrides:
      catchUp in class AbstractDwcControl
      Throws:
      IllegalAccessException - - thrown if an attempt is made to call this method more than once