Class WindowScaler

All Implemented Interfaces:
Scaler

public class WindowScaler
extends ComponentScaler
Extension of ComponentScaler, responsible for Window-derived components' decorations scaling.
Author:
D. Garkov
  • Constructor Details

    • WindowScaler

      public WindowScaler​(float scaleFactor)
  • Method Details

    • scaleComponent

      public void scaleComponent​(Component immediateComponent)
      A method to be called when this WindowScaler has been dispatched to some immediate Component to be scaled.

      Note: Use this only when JFrame or JDialog, are *not* LookAndFeel decorated. Otherwise, this has no effect (Metal LookAndFeel tested). Doesn't override ComponentScaler.coscaleIcon(javax.swing.JComponent)!

      Parameters:
      immediateComponent - to be scaled
    • coscaleIcon

      public void coscaleIcon​(Component component)
      Scales JFrame and JDialog icons. Doesn't override ComponentScaler.coscaleIcon(javax.swing.JComponent)!
      Parameters:
      component -
    • attachSystemWindowResizer

      public static void attachSystemWindowResizer()
      Attach a WindowResizerListener to the default system window Toolkit.
    • resizeWindow

      public static void resizeWindow​(Component window, boolean isPersistent)
      Resizes window components. If the window is not scaling-persistent then its actual scaled size is adjusted by scale-back value, meaning it is scaled only up to a given percentage out of the full scaling factor. Default system windows (through usage of attachSystemWindowResizer()) are set to be impersistent, e.g. dialogs.
      Parameters:
      window - to be resized
      isPersistent - if the window instance would persist through and get rescaled
    • getPreviousRatio

      public static float getPreviousRatio()
      Returns:
      last most recently used scaling ratio/factor.