Package java.awt |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
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.
protected String nameThe logical name of this font.
protected int sizeThe point size of this font.
protected int styleThe style of the font. This is the sum of the constants PLAIN, BOLD, or ITALIC.
public final static int BOLD = 1The bold style constant. This can be combined with the other style constants for mixed styles.
public final static int ITALIC = 2The italicized style constant. This can be combined with the other style constants for mixed styles.
public final static int PLAIN = 0The plain style constant. This can be combined with the other style constants for mixed styles.
public Font(String name, int style, int size)Creates a new font with the specified name, style, and point size.
Parameter Description name the font name style the constant style used size the point size of the font See Also: getFontList in class Toolkit .
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.
Parameter Description obj the object to compare with Overrides:
equals in class Object .
public String getFamily()Return Value:
Returns the platform-specific family name of this font.
See Also: getName .
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.
Parameter Description nm the property name
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.
Parameter Description nm the property name font a default font to return if property 'nm' is not defined
Parameter Description nm the property name font a default font to return if the property isn't defined
public String getName()Return Value:
Returns the logical name of this font.
See Also: getFamily .
public int getSize()Return Value:
Returns the point size of this font.
public int getStyle()Return Value:
Returns the style of this font.
public int hashCode()Return Value:
Returns a hash code value for this font.
Overrides:
hashCode in class Object .
public boolean isBold()Return Value:
Returns true if this font is bold; false otherwise.
See Also: getStyle .
public boolean isItalic()Return Value:
Returns true if this font is italic; false otherwise.
See Also: getStyle .
public boolean isPlain()Return Value:
Returns true if this font is neither bold nor italic; false otherwise.
See Also: getStyle .
public String toString()Return Value:
Returns a string representation of this font.
Overrides:
toString in class Object .