Class Button

  • All Implemented Interfaces:
    Resizable

    public class Button
    extends Object
    implements Resizable
    The `Button` class represents a button component on a screen. It extends the `Components` class and implements the `Resizable` interface.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int c  
      protected CharSets charSets  
      protected int r  
    • Constructor Summary

      Constructors 
      Constructor Description
      Button​(int r, int c)
      Constructs a `Button` with specified row and column positions.
      Button​(int r, int c, String text)
      Constructs a `Button` with specified row, column, and text.
    • Field Detail

      • r

        protected int r
      • c

        protected int c
    • Constructor Detail

      • Button

        public Button​(int r,
                      int c,
                      String text)
        Constructs a `Button` with specified row, column, and text.
        Parameters:
        r - The row position of the button.
        c - The column position of the button.
        text - The text to be displayed on the button.
      • Button

        public Button​(int r,
                      int c)
        Constructs a `Button` with specified row and column positions.
        Parameters:
        r - The row position of the button.
        c - The column position of the button.
    • Method Detail

      • setText

        public void setText​(String text)
        Sets the text to be displayed on the button.
        Parameters:
        text - The new text to be set.
      • getText

        public String getText()
        Gets the text currently displayed on the button.
        Returns:
        The text displayed on the button.
      • place

        public void place​(Screen sc)
        Overrides the `place` method from the `Components` class. Places the button on the provided screen.
        Parameters:
        sc - The `Screen` object on which the button is placed.
      • setWidth

        public void setWidth​(int width)
        Overrides the `setWidth` method from the `Resizable` interface. Sets the width of the button.
        Specified by:
        setWidth in interface Resizable
        Parameters:
        width - The new width of the button.
      • setHeight

        public void setHeight​(int height)
        Overrides the `setHeight` method from the `Resizable` interface. Sets the height of the button (not used in the current implementation).
        Specified by:
        setHeight in interface Resizable
        Parameters:
        height - The new height of the button.