Package io.github.jonestimd.swing
Class ButtonBarLayout
- java.lang.Object
-
- io.github.jonestimd.swing.ButtonBarLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager
,java.awt.LayoutManager2
public class ButtonBarLayout extends java.lang.Object implements java.awt.LayoutManager2
A layout manager for button bars. Makes all of the buttons the same size (the preferred size of the largest button). The buttons can be arranged in a single row or column and can be aligned with the leading or trailing edge of the container.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
alignment
protected int
buttonGap
protected static float
CENTERED
protected static int
DEFAULT_GAP
protected int
orientation
-
Constructor Summary
Constructors Constructor Description ButtonBarLayout()
Create a layout that puts the buttons in a left aligned horizontal row with a button gap of5
.ButtonBarLayout(int orientation, int alignment)
Create a layout with the specified alignment and orientation and a button gap of5
.ButtonBarLayout(int orientation, int buttonGap, int alignment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
void
addLayoutComponent(java.lang.String name, java.awt.Component comp)
float
getLayoutAlignmentX(java.awt.Container target)
float
getLayoutAlignmentY(java.awt.Container target)
void
invalidateLayout(java.awt.Container target)
void
layoutContainer(java.awt.Container target)
java.awt.Dimension
maximumLayoutSize(java.awt.Container target)
java.awt.Dimension
minimumLayoutSize(java.awt.Container target)
java.awt.Dimension
preferredLayoutSize(java.awt.Container target)
void
removeLayoutComponent(java.awt.Component comp)
static ButtonBarLayout
rightAligned()
Create a layout that puts the buttons in a right aligned horizontal row with a button gap of5
.static ButtonBarLayout
vertical()
Create a layout that puts the buttons in a top aligned vertical column with a button gap of5
.
-
-
-
Field Detail
-
DEFAULT_GAP
protected static final int DEFAULT_GAP
- See Also:
- Constant Field Values
-
CENTERED
protected static final float CENTERED
- See Also:
- Constant Field Values
-
buttonGap
protected final int buttonGap
-
orientation
protected final int orientation
-
alignment
protected final int alignment
-
-
Constructor Detail
-
ButtonBarLayout
public ButtonBarLayout()
Create a layout that puts the buttons in a left aligned horizontal row with a button gap of5
.
-
ButtonBarLayout
public ButtonBarLayout(int orientation, int alignment)
Create a layout with the specified alignment and orientation and a button gap of5
.- Parameters:
orientation
-SwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
alignment
-SwingConstants.LEADING
(for top or left) orSwingConstants.TRAILING
(for bottom or right)
-
ButtonBarLayout
public ButtonBarLayout(int orientation, int buttonGap, int alignment)
- Parameters:
orientation
-SwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
buttonGap
- the spacing between buttonsalignment
-SwingConstants.LEADING
(for top or left) orSwingConstants.TRAILING
(for bottom or right)
-
-
Method Detail
-
vertical
public static ButtonBarLayout vertical()
Create a layout that puts the buttons in a top aligned vertical column with a button gap of5
.
-
rightAligned
public static ButtonBarLayout rightAligned()
Create a layout that puts the buttons in a right aligned horizontal row with a button gap of5
.
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager2
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
- Specified by:
maximumLayoutSize
in interfacejava.awt.LayoutManager2
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.Container target)
- Specified by:
getLayoutAlignmentX
in interfacejava.awt.LayoutManager2
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.Container target)
- Specified by:
getLayoutAlignmentY
in interfacejava.awt.LayoutManager2
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
- Specified by:
invalidateLayout
in interfacejava.awt.LayoutManager2
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponent
in interfacejava.awt.LayoutManager
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
- Specified by:
preferredLayoutSize
in interfacejava.awt.LayoutManager
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
- Specified by:
minimumLayoutSize
in interfacejava.awt.LayoutManager
-
layoutContainer
public void layoutContainer(java.awt.Container target)
- Specified by:
layoutContainer
in interfacejava.awt.LayoutManager
-
-