Class WindowDependentSeparator

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.everdro1d.libs.swing.components.WindowDependentSeparator
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class WindowDependentSeparator extends JPanel
A separator that adjusts its width based on the width of a given JFrame.

This class allows you to create a separator that is dependent on a percentage of the frame's width or a fixed amount subtracted from the frame's width. It can be used to create responsive layouts in Swing applications.

See Also:
  • Constructor Details

    • WindowDependentSeparator

      public WindowDependentSeparator(JFrame frame, float percentOfWidth, int height)
      Creates a separator dependent on a % of the frame width.
      Parameters:
      frame - to base width off of
      percentOfWidth - what % of the total should the separator fill
      height - how many px tall should the bar be
    • WindowDependentSeparator

      public WindowDependentSeparator(JFrame frame, int amtSubtract, int height)
      Creates a separator dependent on (frameWidth - (amtSubtract * 2)).
      Parameters:
      frame - to base width off of
      amtSubtract - number of px to subtract from width
      height - how many px tall should the bar be
  • Method Details

    • updateWidth

      public void updateWidth(JFrame frame, float percentOfWidth)
      Updates an existing separator dependent on a % of the frame width. Uses current height.
      Parameters:
      frame - to base width off of
      percentOfWidth - what % of the total should the separator fill
    • updateSize

      public void updateSize(JFrame frame, float percentOfWidth, int height)
      Updates an existing separator dependent on a % of the frame width.
      Parameters:
      frame - to base width off of
      percentOfWidth - what % of the total should the separator fill
      height - how many px tall should the bar be
    • updateWidth

      public void updateWidth(JFrame frame, int amtSubtract)
      Updates an existing separator dependent on (frameWidth - (amtSubtract * 2)). Uses current height.
      Parameters:
      frame - to base width off of
      amtSubtract - number of px to subtract from width
    • updateSize

      public void updateSize(JFrame frame, int amtSubtract, int height)
      Updates an existing separator dependent on (frameWidth - (amtSubtract * 2)).
      Parameters:
      frame - to base width off of
      amtSubtract - number of px to subtract from width
      height - how many px tall should the bar be
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JPanel