Class ResizeWindowButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public abstract class ResizeWindowButton extends JButton
Abstract class for a button that resizes a window when clicked.

This class provides functionality to create a button that can resize a JFrame from a specified width and height, with customizable multipliers for resizing. It also allows for custom actions to be performed after resizing.

Example Usage:

 JFrame frame = new JFrame();
 ResizeWindowButton resizeButton = new ResizeWindowButton(frame, 800, 600, 1.5f, 1.5f, true) {
   @Override
   public void customResizeActions() {
    // Custom actions to perform after resizing
    System.out.println("Window resized to: " + getNewWidth() + "x" + getNewHeight());
    }
 };

 
See Also:
  • Constructor Details

    • ResizeWindowButton

      public ResizeWindowButton(JFrame frame, int baseWidth, int baseHeight, float xMult, float yMult, boolean debug)
      Constructor for ResizeWindowButton.
      Parameters:
      frame - the JFrame to resize
      baseWidth - the base width of the window
      baseHeight - the base height of the window
      xMult - the multiplier for width resizing
      yMult - the multiplier for height resizing
      debug - whether to enable debug output
  • Method Details

    • customResizeActions

      public abstract void customResizeActions()
      Custom actions to perform after resizing the window.

      This method can be overridden to provide custom behavior after the window has been resized.

    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JButton
    • resizeWindowButtonColorChange

      public void resizeWindowButtonColorChange()
      Overload method for default color based on root pane foreground color.
      See Also:
    • resizeWindowButtonColorChange

      public void resizeWindowButtonColorChange(Color color)
      Change the color of the resize icon based on param
      Parameters:
      color - new icon color
    • getBaseWidth

      public int getBaseWidth()
      Retrieve the base width (width before resize).
      Returns:
      the base width of the window
    • getBaseHeight

      public int getBaseHeight()
      Retrieve the base height (height before resize).
      Returns:
      the base height of the window
    • getNewWidth

      public int getNewWidth()
      Retrieve the new width (width after resize).
      Returns:
      the new width of the window
    • getNewHeight

      public int getNewHeight()
      Retrieve the new height (height after resize).
      Returns:
      the new height of the window
    • getXMultiplier

      public float getXMultiplier()
      Retrieve the multiplier for width resizing.
      Returns:
      the multiplier for width resizing
    • getYMultiplier

      public float getYMultiplier()
      Retrieve the multiplier for height resizing.
      Returns:
      the multiplier for height resizing
    • isMaximized

      public boolean isMaximized()
      Retrieve whether the window is maximized (using this button).
      Returns:
      true if the window is maximized, false otherwise
    • setXMultiplier

      public void setXMultiplier(float newXMult)
      Set the width multiplier for resizing.
      Parameters:
      newXMult - the new width multiplier
    • setYMultiplier

      public void setYMultiplier(float newYMult)
      Set the height multiplier for resizing.
      Parameters:
      newYMult - the new height multiplier