![]() |
![]() |
Java Multithreading | |
Creating a Thread | |
Thread Life Cycle | |
Thread Exceptions | |
Thread Synchronization |
Intro. to Graphics class | |
Drawing - Lines , Rectangles | |
Drawing - Circles and Ellipse | |
Drawing - Arcs | |
Drawing - Polygons | |
Drawing - Bar Charts |
Java Programs | |
Java Keywords Dictionary | |
Java Interview Questions |
A font determines look of the text when it is painted. Font is used when painting text on a Graphics context and is a property of AWT Component.
All Fonts are stored into Font class.
1. To set the font to applet first of all create an object of Font class.
Font fontObj = new Font (String FontName, int FontStyle, int FontSize);
Explanation
Constant | Description |
---|---|
Font.BOLD | It makes the font style bold. |
Font.ITALIC | It makes the font style Italic. |
Font.PLAIN | It make the font style plain. |
Multiple font style can be applied by using OR | symbol Ex- Font.BOLD|Font.PLAIN
2. After creating an object java has setFont () method to set the font.
void setFont (fontObj);
Font myFont = new Font("Consolas",Font.BOLD,30); setFont (myFont);
NOTE : Applet has default fontName = 'Dialog', Font size = 12 , font style = 'PLAIN'. |
Method Name | Syntax | Description |
---|---|---|
getFamily | String getFamily() | This method returns the family name of current font object. |
getFont | static Font getFont(String nm) | This method returns a Font Object from system properties list. |
getFontName | String getFontName() | This method returns the font face name. |
getSize | int getSize() | This method returns the point size of font, rounded to an integer. |
getStyle | int getStyle() | This method returns the style of the font. |
isPlain | boolean isPlain() | This method returns a boolean true if font is plain otherwise returns false. |
isItalic | boolean isItalic() | This method returns a boolean true if font is italic otherwise returns false. |
isBol | boolean isBol() | This method returns a boolean true if font is Bold otherwise returns false. |
Program to make use of Font class methods.