|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
com.ccg.awt.InsetPanel
public class InsetPanel
A panel with a decoratable border area.
This class extends the standard Panel object in
a way that one can paint fancy little border areas around the
exteriour of the contained components. This can be used to add
spacing for the entire panel area. The default implementation of
the border painting is to simply fill the
border area with the background color, and then draw some
rectangles in the foreground color. Classes which extend this
object will probably just need to implement the paintEdges(java.awt.Graphics)
method.
Note, you may want to implement the update() method in any class which extends this one. The default
implementation this class inherits is to blank the area and then
paint it. It seems that this is seldom what you
want.
The following example shows how to add a standard component to a applet which will have a 8 pixel gap filled in the color red
around the component which was added (copy and paste the code to a
file called "IC.java"):
import com.ccg.awt.*;
import java.awt.*;
public class IC extends java.applet.Applet {
public void init() {
InsetPanel ic = new InsetPanel();
ic.setBackground(Color.green);
ic.setForeground(Color.red);
ic.setEvenGap(16);
ic.setRight(48);
ic.add(new Label("Hello World"));
add(ic);
}
}
paintEdges(java.awt.Graphics),
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Panel |
|---|
Panel.AccessibleAWTPanel |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
InsetPanel()
Default constructor of the object. |
|
| Method Summary | |
|---|---|
int |
getBottom()
Get the inset from the bottom edge |
Insets |
getInsets()
Get the insets from the edges |
int |
getLeft()
Get the inset from the left edge |
int |
getRight()
Get the inset from the right edge |
int |
getTop()
Get the inset from the top edge |
void |
paint(Graphics g)
Paint the edges and components. |
void |
paintEdges(Graphics g)
Paint the "border" edges. |
void |
setBottom(int val)
Set the inset from the bottom edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels. |
void |
setEvenGap(int gap)
Set the indentation to the same number of pixels. |
void |
setInsets(Insets val)
Set the insets from the edges |
void |
setLeft(int val)
Set the inset from the left edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels. |
void |
setRight(int val)
Set the inset from the right edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels. |
void |
setTop(int val)
Set the inset from the top edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels. |
| Methods inherited from class java.awt.Panel |
|---|
addNotify, getAccessibleContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public InsetPanel()
setEvenGap(int)| Method Detail |
|---|
public void paint(Graphics g)
edges and components.
This method first invokes paintEdges(java.awt.Graphics) to paint any edge
decorations. It then invokes its parent's method to paint the
components contained.
paint in class Containerg - Graphics object to drawn onto.paintEdges(java.awt.Graphics)public void paintEdges(Graphics g)
It should be noted that this method is invoked PRIOR to the painting of the interior components. So, if you draw outside of your edge boundaries, it will probably be drawn over by the interior components.
g - Graphics object to drawn onto.paint(java.awt.Graphics)public void setLeft(int val)
inset from the left edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels.
val - The inset (in pixels) from the left side.getLeft()public int getLeft()
inset from the left edge
setLeft(int)public void setRight(int val)
inset from the right edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels.
val - The inset (in pixels) from the right side.getRight()public int getRight()
inset from the right edge
setRight(int)public void setTop(int val)
inset from the top edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels.
val - The inset (in pixels) from the top side.getTop()public int getTop()
inset from the top edge
setTop(int)public void setBottom(int val)
inset from the bottom edge
After adjusting this value (and any others which may affect the
components size), you will want to layout you panels.
val - The inset (in pixels) from the bottom side.getBottom()public int getBottom()
inset from the bottom edge
setBottom(int)public void setEvenGap(int gap)
left, right, top and
bottom) to the same value in one shot.
gap - The gap (in pixels) you want around the components in the panel.setInsets(java.awt.Insets)public void setInsets(Insets val)
insets from the edges
val - New Insets value to assign.getInsets()public Insets getInsets()
insets from the edges
getInsets in class ContainersetInsets(java.awt.Insets)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||