Package jexer

Class TButton

  • All Implemented Interfaces:
    java.lang.Comparable<TWidget>

    public class TButton
    extends TWidget
    TButton implements a simple button. To make the button do something, pass a TAction class to its constructor.
    See Also:
    TAction.DO()
    • Constructor Detail

      • TButton

        public TButton​(TWidget parent,
                       java.lang.String text,
                       int x,
                       int y,
                       TAction action)
        Public constructor.
        Parameters:
        parent - parent widget
        text - label on the button
        x - column relative to parent
        y - row relative to parent
        action - to call when button is pressed
    • Method Detail

      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse button presses.
        Overrides:
        onMouseDown in class TWidget
        Parameters:
        mouse - mouse button event
      • onMouseUp

        public void onMouseUp​(TMouseEvent mouse)
        Handle mouse button releases.
        Overrides:
        onMouseUp in class TWidget
        Parameters:
        mouse - mouse button release event
      • onMouseMotion

        public void onMouseMotion​(TMouseEvent mouse)
        Handle mouse movements.
        Overrides:
        onMouseMotion in class TWidget
        Parameters:
        mouse - mouse motion event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWidget
        Parameters:
        keypress - keystroke event
      • setWidth

        public void setWidth​(int width)
        Override TWidget's width: we can only set width at construction time.
        Overrides:
        setWidth in class TWidget
        Parameters:
        width - new widget width (ignored)
      • setHeight

        public void setHeight​(int height)
        Override TWidget's height: we can only set height at construction time.
        Overrides:
        setHeight in class TWidget
        Parameters:
        height - new widget height (ignored)
      • draw

        public void draw()
        Draw a button with a shadow.
        Overrides:
        draw in class TWidget
      • getMnemonic

        public MnemonicString getMnemonic()
        Get the mnemonic string for this button.
        Returns:
        mnemonic string
      • dispatch

        public void dispatch()
        Act as though the button was pressed. This is useful for other UI elements to get the same action as if the user clicked the button.
      • setShadowColor

        public void setShadowColor​(CellAttributes color)
        Set the background color used for the button "shadow". If null, no shadow will be drawn.
        Parameters:
        color - the new background color, or null for no shadow