Package view

Class ControlPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ControlPanel extends JPanel
Implementation of ControlPanel component.
See Also:
  • Constructor Details

    • ControlPanel

      public ControlPanel(Game game)
      Constructs a new ControlPanel instance with dependency injection.
      Parameters:
      game - Game dependency injection
  • Method Details

    • getButtons

      public JRoundedButton[] getButtons()
      Returns the buttons of the panel.
      Returns:
      the buttons of the panel
    • resize

      public void resize()
      Resizes the panel and buttons.
    • updateButtonText

      public void updateButtonText()
      Updates the buttons text in the panel.
    • attachActionListener

      public void attachActionListener(int idx, ActionListener e)
      Adds an ActionListener to a button in the panel.
      Parameters:
      idx - the index of the button
      e - the ActionListener we want to add
    • setButtonColor

      public void setButtonColor(int idx, Color color, int idx2)
      Sets a buttons color in the panel.
      Parameters:
      idx - the index of the button
      color - the color
      idx2 - the index of the color type we set
    • setButtonColors

      public void setButtonColors(int idx, Color[] colors)
      Sets a buttons three color types at once.
      Parameters:
      idx - the index of the button
      colors - the list of colors to set to the color types
    • hideButton

      public void hideButton(int idx)
      Hides a button in the panel.
      Parameters:
      idx - the index of the button
    • setButtonText

      public void setButtonText(int idx, String text)
      Sets a buttons text.
      Parameters:
      idx - the index of the button
      text - the text we want to set
    • setButtonSize

      public void setButtonSize(int idx, Dimension dim)
      Sets a buttons size.
      Parameters:
      idx - the index of the button
      dim - the size we want to set
    • hideControlPanel

      public void hideControlPanel()
      Hides the panel.
    • showControlPanel

      public void showControlPanel()
      Shows the panel.
    • paintComponent

      protected void paintComponent(Graphics g)
      The paintComponent method of the class.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - graphics we use