Package kg.apc.jmeter.gui
Class ComponentBorder
- java.lang.Object
-
- kg.apc.jmeter.gui.ComponentBorder
-
- All Implemented Interfaces:
javax.swing.border.Border
public class ComponentBorder extends java.lang.Object implements javax.swing.border.BorderThe 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. From: http://tips4java.wordpress.com/2009/09/27/component-border/
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classComponentBorder.Edge
-
Constructor Summary
Constructors Constructor Description ComponentBorder(javax.swing.JComponent component)Convenience constructor that uses the default edge (Edge.RIGHT) and alignment (CENTER).ComponentBorder(javax.swing.JComponent component, ComponentBorder.Edge edge)Convenience constructor that uses the default alignment (CENTER).ComponentBorder(javax.swing.JComponent component, ComponentBorder.Edge edge, float alignment)Main constructor to create a ComponentBorder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAlignment()Get the component alignment along the Border Edgejava.awt.InsetsgetBorderInsets(java.awt.Component c)ComponentBorder.EdgegetEdge()Get the Edge the component is positioned alongintgetGap()Get the gap between the border component and the parent componentvoidinstall(javax.swing.JComponent parent)booleanisAdjustInsets()booleanisBorderOpaque()voidpaintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)In this case a real component is to be painted.voidsetAdjustInsets(boolean adjustInsets)voidsetAlignment(float alignment)Set the component alignment along the Border EdgevoidsetEdge(ComponentBorder.Edge edge)Set the Edge the component is positioned alongvoidsetGap(int gap)Set the gap between the border component and the parent component
-
-
-
Field Detail
-
LEADING
public static final float LEADING
- See Also:
- Constant Field Values
-
CENTER
public static final float CENTER
- See Also:
- Constant Field Values
-
TRAILING
public static final float TRAILING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ComponentBorder
public ComponentBorder(javax.swing.JComponent component)
Convenience constructor that uses the default edge (Edge.RIGHT) and alignment (CENTER).- Parameters:
component- the component to be added in the Border area
-
ComponentBorder
public ComponentBorder(javax.swing.JComponent component, ComponentBorder.Edge edge)Convenience constructor that uses the default alignment (CENTER).- Parameters:
component- the component to be added in the Border areaedge- a valid Edge enum of TOP, LEFT, BOTTOM, RIGHT
-
ComponentBorder
public ComponentBorder(javax.swing.JComponent component, ComponentBorder.Edge edge, float alignment)Main constructor to create a ComponentBorder.- Parameters:
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
-
isAdjustInsets
public boolean isAdjustInsets()
-
setAdjustInsets
public void setAdjustInsets(boolean adjustInsets)
-
getAlignment
public float getAlignment()
Get the component alignment along the Border Edge- Returns:
- the alignment
-
setAlignment
public final void setAlignment(float alignment)
Set the component alignment along the Border Edge- Parameters:
alignment- a value in the range 0 - 1.0. Standard values would be CENTER (default), LEFT and RIGHT.
-
getEdge
public ComponentBorder.Edge getEdge()
Get the Edge the component is positioned along- Returns:
- the Edge
-
setEdge
public final void setEdge(ComponentBorder.Edge edge)
Set the Edge the component is positioned along- Parameters:
edge- the Edge the component is position on.
-
getGap
public int getGap()
Get the gap between the border component and the parent component- Returns:
- the gap in pixels.
-
setGap
public void setGap(int gap)
Set the gap between the border component and the parent component- Parameters:
gap- the gap in pixels (default is 5)
-
getBorderInsets
public java.awt.Insets getBorderInsets(java.awt.Component c)
- Specified by:
getBorderInsetsin interfacejavax.swing.border.Border
-
isBorderOpaque
public boolean isBorderOpaque()
- Specified by:
isBorderOpaquein interfacejavax.swing.border.Border
-
paintBorder
public void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)In this case a real component is to be painted. Setting the location of the component will cause it to be painted at that location.- Specified by:
paintBorderin interfacejavax.swing.border.Border
-
install
public void install(javax.swing.JComponent parent)
-
-