Pen Class

Pen Class

This Package | All Packages

public final class Pen

This is a graphics pen. Pens are used to draw lines on graphics surfaces.

Fields
Name Description
BLACK Topic under construction.
NULL Topic under construction.
STYLE_DASH Creates a pen style that consists of a series of dashed lines: --------
STYLE_DASHDOT Creates a pen style that consists of a dash, followed by a dot: _ .
STYLE_DASHDOTDOT Creates a pen style that consists of a dash, followed by two dots: _ .
STYLE_DOT Creates a pen style that consists of a dotted line: ...........
STYLE_INSIDEFRAME Allows a pen to be drawn within a bounding rectangle.
STYLE_NULL Creates a "null" pen, which is a pen that doesn't draw at all.
STYLE_SOLID Creates a pen style that consists of a solid line: ___________
WHITE Topic under construction.

Constructors
Name Description
Pen(Color color) Creates a new pen with the given color.
Pen(Color color, int style) Creates a new pen with the given color and style.
Pen(Color color, int style, int width) Creates a pen with the given style, color, and width.
Pen(int handle) Creates a pen based on an existing Win32 HPEN handle.

Methods
Name Description
equals(Object obj) Checks equality of two pens.
finalize() throws Throwable Finalizer for the pen; cleans up Win32 resources.
getColor() Returns the color of this pen.
getHandle() Returns the Win32 handle for this pen.
getStyle() Returns the pen style.
getWidth() Returns the pen width.
hashCode() Computes the hash code for this object.

Fields

Pen.BLACK

Syntax
public static final Pen BLACK;
Description
Topic under construction.

Pen.NULL

Syntax
public static final Pen NULL;
Description
Topic under construction.

Pen.STYLE_DASH

Syntax
public static final int STYLE_DASH;
Description
Creates a pen style that consists of a series of dashed lines: --------

Pen.STYLE_DASHDOT

Syntax
public static final int STYLE_DASHDOT;
Description
Creates a pen style that consists of a dash, followed by a dot: _ . _ . _ .

Pen.STYLE_DASHDOTDOT

Syntax
public static final int STYLE_DASHDOTDOT;
Description
Creates a pen style that consists of a dash, followed by two dots: _ . . _ . . _ . .

Pen.STYLE_DOT

Syntax
public static final int STYLE_DOT;
Description
Creates a pen style that consists of a dotted line: ...........

Pen.STYLE_INSIDEFRAME

Syntax
public static final int STYLE_INSIDEFRAME;
Description
Allows a pen to be drawn within a bounding rectangle. Using this style allows you to have a wide pen that automatically conforms to the interior of a rectangle.

Pen.STYLE_NULL

Syntax
public static final int STYLE_NULL;
Description
Creates a "null" pen, which is a pen that doesn't draw at all. This is useful when you have a function that always draws a border, but you don't want the border.

Pen.STYLE_SOLID

Syntax
public static final int STYLE_SOLID;
Description
Creates a pen style that consists of a solid line: ___________

Pen.WHITE

Syntax
public static final Pen WHITE;
Description
Topic under construction.

Constructors

Pen.Pen

Syntax 1
public Pen( Color color );
Parameters
color
Color object specifying the color of the pen.
Description

Creates a new pen with the given color. The style of the pen will be solid [STYLE_SOLID]. The width of the pen is one [1] pixel.



Syntax 2
public Pen( Color color, int style );
Parameters
color
Color object with the pen's color.
style
Integer with the style of pen to create.
Description

Creates a new pen with the given color and style. The style should be one of the constants specified in the Pen class. The width of the pen is one [1] pixel.



Syntax 3
public Pen( Color color, int style, int width );
Parameters
color
Color object with the pen's color.
style
Integer with the style of the pen to create.
width
Integer with the desired width of the pen.
Description

Creates a pen with the given style, color, and width. The style should be one of the constants specified in the Pen class, and the width should be be greater than zero.

Exceptions

IllegalArgumentException thrown if there is an illegal argument.



Syntax 4
public Pen( int handle );
Parameters
handle
The Win32 HPEN to create the Pen object from.
Description

Creates a pen based on an existing Win32 HPEN handle.

Methods

Pen.equals

Syntax
public boolean equals( Object obj );
Parameters
obj
Object to compare equality to.
Return Value

Returns true if the given object is equivalent to this object.

Description

Checks equality of two pens.

Pen.finalize

Syntax
protected void finalize() throws Throwable;
Description

Finalizer for the pen; cleans up Win32 resources.

Pen.getColor

Syntax
public Color getColor();
Return Value

Returns the pen color.

Description

Returns the color of this pen.

Pen.getHandle

Syntax
public int getHandle();
Return Value

Returns a Win32 HPEN.

Description

Returns the Win32 handle for this pen.

Pen.getStyle

Syntax
public int getStyle();
Return Value

Returns one of the Pen.STYLE_ constants.

Description

Returns the pen style.

Pen.getWidth

Syntax
public int getWidth();
Return Value

Returns the width of the pen.

Description

Returns the pen width.

Pen.hashCode

Syntax
public int hashCode();
Return Value

Returns an integer hash code value.

Description

Computes the hash code for this object.