Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Font

Fields , Constructors , Methods

public  class  java.awt.Font
    extends  java.lang.Object  
{
        // Fields
    protected String name;	
    protected int size;	
    protected int style;	

        // style has the following bit masks
    public final static int BOLD;	
    public final static int ITALIC;	
    public final static int PLAIN	

        // Constructors
    public Font(String  name, int  style, int  size);	

        // Methods
    public boolean equals(Object  obj);	
    public String getFamily();	
    public static Font getFont(String  nm);	
    public static Font getFont(String  nm, Font  font);	
    public String getName();	
    public int getSize();	
    public int getStyle();	
    public int hashCode();	
    public boolean isBold();	
    public boolean isItalic();	
    public boolean isPlain();	
    public String toString();	
}

This class represents a font.


Fields


name

protected String name 

The logical name of this font.


size

protected int size 

The point size of this font.


style

protected int style 

The style of the font. This is the sum of the constants PLAIN, BOLD, or ITALIC.


BOLD

public final static int BOLD = 1 

The bold style constant. This can be combined with the other style constants for mixed styles.


ITALIC

public final static int ITALIC = 2 

The italicized style constant. This can be combined with the other style constants for mixed styles.


PLAIN

public final static int PLAIN = 0 

The plain style constant. This can be combined with the other style constants for mixed styles.


Constructors


Font

public Font(String  name, int  style, int  size) 

Creates a new font with the specified name, style, and point size.

ParameterDescription
name the font name
style the constant style used
size the point size of the font

See Also: getFontList in class Toolkit .


Methods


equals

public boolean equals(Object  obj) 

The result is true if and only if the argument is not null and is a Font object with the same name, same style, and same point size as this Font..

Return Value:

Returns true if the objects are the same; false otherwise.

ParameterDescription
obj the object to compare with

Overrides:

equals in class Object .


getFamily

public String getFamily() 

Return Value:

Returns the platform-specific family name of this font.

See Also: getName .


getFont

public static Font getFont(String  nm) 

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty . The string value of this property is then interpreted as a font as described in the getFont method of two argument .

If the specified property is not found, null is returned.

Return Value:

Returns the Font value of the property.

ParameterDescription
nm the property name


getFont

public static Font getFont(String  nm, Font  font) 

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty . The string value of this property is then interpreted as a font.

The property value should be one of the following forms:

fontname-style-pointsize fontname-pointsize fontname-style fontname

where style is one of the three strings "bold", "bolditalic" or "italic" and pointsize is a decimal representation of the pointsize.

The default style is PLAIN. The default pointsize is 12.

If the specified property is not found, the font argument is returned instead.

Return Value:

Returns the Font value of the property.

ParameterDescription
nm the property name
font a default font to return if property 'nm' is not defined

ParameterDescription
nm the property name
font a default font to return if the property isn't defined


getName

public String getName() 

Return Value:

Returns the logical name of this font.

See Also: getFamily .


getSize

public int getSize() 

Return Value:

Returns the point size of this font.


getStyle

public int getStyle() 

Return Value:

Returns the style of this font.

See Also: isPlain isBold isItalic .


hashCode

public int hashCode() 

Return Value:

Returns a hash code value for this font.

Overrides:

hashCode in class Object .


isBold

public boolean isBold() 

Return Value:

Returns true if this font is bold; false otherwise.

See Also: getStyle .


isItalic

public boolean isItalic() 

Return Value:

Returns true if this font is italic; false otherwise.

See Also: getStyle .


isPlain

public boolean isPlain() 

Return Value:

Returns true if this font is neither bold nor italic; false otherwise.

See Also: getStyle .


toString

public String toString() 

Return Value:

Returns a string representation of this font.

Overrides:

toString in class Object .



Top© 1996 Sun Microsystems, Inc. All rights reserved.