|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.wordpress.tipsforjava.swing.border.ComponentBorder
public class ComponentBorder extends Object
The ComponentBorder class allows you to place a real component in the space reserved for painting the Border of a component. This class takes advantage of the knowledge that all Swing components are also Containers. By default the layout manager is null, so we should be able to place a child component anywhere in the parent component. In order to prevent the child component from painting over top of the parent component a Border is added to the parent componet such that the insets of the Border will reserve space for the child component to be painted without affecting the parent component.
| Nested Class Summary | |
|---|---|
enum |
ComponentBorder.Edge
|
| Field Summary | |
|---|---|
static float |
CENTER
|
static float |
LEADING
The ComponentBorder class allows you to place a real component in the space reserved for painting the Border of a component. |
static float |
TRAILING
|
private boolean |
adjustInsets
|
private float |
alignment
|
private Insets |
borderInsets
|
private JComponent |
component
|
private ComponentBorder.Edge |
edge
|
private int |
gap
|
private JComponent |
parent
|
| Constructor Summary | |
ComponentBorder(JComponent component)
Convenience constructor that uses the default edge (Edge.RIGHT) and alignment (CENTER). |
|
ComponentBorder(JComponent component, ComponentBorder.Edge edge)
Convenience constructor that uses the default alignment (CENTER). |
|
ComponentBorder(JComponent component, ComponentBorder.Edge edge, float alignment)
Main constructor to create a ComponentBorder. |
|
| Method Summary | |
|---|---|
private void
|
adjustBorderInsets()
|
private void
|
determineInsetsAndAlignment()
The insets need to be determined so they are included in the preferred size of the component the Border is attached to. |
float
|
getAlignment()
Get the component alignment along the Border Edge |
Insets
|
getBorderInsets(Component c)
|
ComponentBorder.Edge
|
getEdge()
Get the Edge the component is positioned along |
int
|
getGap()
Get the gap between the border component and the parent component |
void
|
install(JComponent parent)
|
boolean
|
isAdjustInsets()
|
boolean
|
isBorderOpaque()
|
void
|
paintBorder(Component c, Graphics g, int x, int y, int width, int height)
In this case a real component is to be painted. |
void
|
setAdjustInsets(boolean adjustInsets)
|
void
|
setAlignment(float alignment)
Set the component alignment along the Border Edge |
void
|
setEdge(ComponentBorder.Edge edge)
Set the Edge the component is positioned along |
void
|
setGap(int gap)
Set the gap between the border component and the parent component |
ComponentBorder
|
valueOf(String name)
Returns the enum constant of this type with the specified name. |
ComponentBorder[]
|
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
public static final float CENTER
public static final float LEADING
public static final float TRAILING
private boolean adjustInsets
private float alignment
private Insets borderInsets
private JComponent component
private ComponentBorder.Edge edge
private int gap
private JComponent parent
| Constructor Detail |
|---|
public ComponentBorder(JComponent component)
component - the component to be added in the Border area
public ComponentBorder(JComponent component, ComponentBorder.Edge edge)
component - the component to be added in the Border areaedge - a valid Edge enum of TOP, LEFT, BOTTOM, RIGHT
public ComponentBorder(JComponent component, ComponentBorder.Edge edge, float alignment)
component - the component to be added in the Border areaedge - a valid Edge enum of TOP, LEFT, BOTTOM, RIGHTalignment - the alignment of the component along the
specified Edge. Must be in the range 0 - 1.0.
| Method Detail |
|---|
private void adjustBorderInsets()
private void determineInsetsAndAlignment()
public float getAlignment()
public Insets getBorderInsets(Component c)
public ComponentBorder.Edge getEdge()
public int getGap()
public void install(JComponent parent)
public boolean isAdjustInsets()
public boolean isBorderOpaque()
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
public void setAdjustInsets(boolean adjustInsets)
public void setAlignment(float alignment)
alignment - a value in the range 0 - 1.0. Standard values would be
CENTER (default), LEFT and RIGHT.
public void setEdge(ComponentBorder.Edge edge)
edge - the Edge the component is position on.
public void setGap(int gap)
gap - the gap in pixels (default is 5)
ComponentBorder valueOf(String name)
ComponentBorder[] values()
Groovy Documentation