Brush Class

Brush Class

This Package | All Packages

public final class Brush

This class encapsulates a Windows brush. Brushes are used for filling areas of a window or a graphics region. You can create a brush whose appearance is based on the constants defined in this class, or you can create a brush based on a bitmap.

Fields
Name Description
BLACK Standard black brush.
DARKGRAY Standard dark gray brush.
GRAY Standard gray brush.
HALFTONE Standard halftone brush.
HOLLOW Hollow brush.
LIGHTGRAY Light gray brush.
NULL Null brush.
STYLE_BDIAGONAL Standard brush style consisting of backward diagonal lines.
STYLE_DIAGCROSS Standard brush style consisting of diagonal crisscross lines.
STYLE_FDIAGONAL Standard brush style consisting of forward diagonal lines.
STYLE_HORIZONTAL Standard brush style consisting of horizontal lines.
STYLE_VERTICAL Standard brush style consisting of vertical lines.
WHITE White brush.

Constructors
Name Description
Brush(Color color) Creates a new solid brush of the specified color.
Brush(Color color, int style) Creates a new brush of the style and color.
Brush(Bitmap bmp) Creates a brush based on the specified bitmap.
Brush(int handle) Creates a brush based on an existing Win32 handle.

Methods
Name Description
equals(Object obj) Retrieves a boolean value that indicates whether the specified object is equivalent to this brush.
finalize() throws Throwable Cleans up the Win32 resources associated with this brush.
getColor() Retrieves the color of this brush.
getHandle() Retrieves the Win32 handle of the brush.
getStyle() Retrieves the style of the brush.
hashCode() Computes and returns the hash code for this Brush object.

Fields

Brush.BLACK

Syntax
public static final Brush BLACK;
Description
Standard black brush.

Brush.DARKGRAY

Syntax
public static final Brush DARKGRAY;
Description
Standard dark gray brush.

Brush.GRAY

Syntax
public static final Brush GRAY;
Description
Standard gray brush.

Brush.HALFTONE

Syntax
public static final Brush HALFTONE;
Description
Standard halftone brush.

Brush.HOLLOW

Syntax
public static final Brush HOLLOW;
Description
Hollow brush. This brush paints nothing.

Brush.LIGHTGRAY

Syntax
public static final Brush LIGHTGRAY;
Description
Light gray brush.

Brush.NULL

Syntax
public static final Brush NULL;
Description
Null brush. The behavior of this brush is identical to a hollow brush.

Brush.STYLE_BDIAGONAL

Syntax
public static final int STYLE_BDIAGONAL;
Description
Standard brush style consisting of backward diagonal lines.

Brush.STYLE_DIAGCROSS

Syntax
public static final int STYLE_DIAGCROSS;
Description
Standard brush style consisting of diagonal crisscross lines.

Brush.STYLE_FDIAGONAL

Syntax
public static final int STYLE_FDIAGONAL;
Description
Standard brush style consisting of forward diagonal lines.

Brush.STYLE_HORIZONTAL

Syntax
public static final int STYLE_HORIZONTAL;
Description
Standard brush style consisting of horizontal lines.

Brush.STYLE_VERTICAL

Syntax
public static final int STYLE_VERTICAL;
Description
Standard brush style consisting of vertical lines.

Brush.WHITE

Syntax
public static final Brush WHITE;
Description
White brush.

Constructors

Brush.Brush

Syntax 1
public Brush( Color color );
Parameters
color
The color of the brush.
Description

Creates a new solid brush of the specified color.



Syntax 2
public Brush( Color color, int style );
Parameters
color
The color of the brush.
style
One of the Brush.STYLE_ constants.
Description

Creates a new brush of the style and color.



Syntax 3
public Brush( Bitmap bmp );
Parameters
bmp
The bitmap from which to create the brush.
Description

Creates a brush based on the specified bitmap.



Syntax 4
public Brush( int handle );
Parameters
handle
The Win32 brush handle.
Description

Creates a brush based on an existing Win32 handle. The brush does not own the handle.

Methods

Brush.equals

Syntax
public boolean equals( Object obj );
Parameters
obj
The Object to which to compare this brush.
Return Value

Returns true if the specified object is equalivalent to this brush; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether the specified object is equivalent to this brush.

Brush.finalize

Syntax
protected void finalize() throws Throwable;
Description

Cleans up the Win32 resources associated with this brush.

Exceptions

Throwable thrown if resources associated with this brush cannot be freed.

Brush.getColor

Syntax
public Color getColor();
Return Value

Returns the brush color.

Description

Retrieves the color of this brush.

Brush.getHandle

Syntax
public int getHandle();
Return Value

Returns a Win32 handle value.

Description

Retrieves the Win32 handle of the brush.

Brush.getStyle

Syntax
public int getStyle();
Return Value

Returns one of the Brush.STYLE_ constants.

Description

Retrieves the style of the brush.

Brush.hashCode

Syntax
public int hashCode();
Return Value

Returns an integer hash code value.

Description

Computes and returns the hash code for this Brush object.