1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* Create Bold and Italic Font Example This java example shows how to create bold and italic font using Java AWT Font class. */ import java.applet.Applet; import java.awt.Font; import java.awt.Graphics; /* <applet code="CreateBoldItalicFontExample" width=200 height=200> </applet> */ public class CreateBoldItalicFontExample extends Applet{ public void paint(Graphics g) { /* * To create a bold and italic font, use * Font(String name,int style, int size) * constructor of font class. * * sepcify Font.BOLD | Font.ITALIC as style. */ Font myFont = new Font("Courier", Font.BOLD | Font.ITALIC ,20); g.setFont(myFont); g.drawString("Bold & Italic Font Example", 10, 50); } } |
Example Output
Add Comment