All Implemented Interfaces:
Control, View

public class ButtonView extends BoxView
ButtonView is a View with border and text acting as a button.
  • Constructor Details

    • ButtonView

      public ButtonView()
    • ButtonView

      public ButtonView(String text)
    • ButtonView

      public ButtonView(String text, Runnable action)
  • Method Details

    • initInternal

      protected void initInternal()
      Description copied from class: AbstractView
      Internal init method called from AbstractView.init(). Override to do something usefull. Typically key and mousebindings are registered from this method.
      Overrides:
      initInternal in class AbstractView
    • getKeyHandler

      public KeyHandler getKeyHandler()
      Description copied from class: AbstractView
      Handles keys by dispatching registered command runnable into an event loop. Override to change default behaviour.
      Specified by:
      getKeyHandler in interface View
      Overrides:
      getKeyHandler in class AbstractView
      Returns:
      a view key handler
      See Also:
    • getMouseHandler

      public MouseHandler getMouseHandler()
      Description copied from class: AbstractView
      Handles mouse events by dispatching registered consumers into an event loop. Override to change default behaviour.
      Specified by:
      getMouseHandler in interface View
      Overrides:
      getMouseHandler in class AbstractView
      Returns:
      a view mouse handler
      See Also:
    • getBackgroundStyle

      protected String getBackgroundStyle()
      Overrides:
      getBackgroundStyle in class BoxView
    • drawInternal

      protected void drawInternal(Screen screen)
      Description copied from class: BoxView
      Possibly draws a box around this view and title in a box top boundary. Also calls a draw function if defined.
      Overrides:
      drawInternal in class BoxView
      Parameters:
      screen - the screen
    • getPreferredDimension

      public Dimension getPreferredDimension()
    • setText

      public void setText(String text)
    • setAction

      public void setAction(Runnable action)