/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import javax.swing.* ; 

2. import java.awt.* ; 

3. import java.awt.event.*; 

4.  

5. public class FontsSw 

6.     extends JApplet 

7.     implements ActionListener 

8.

9.   JButton  btn ; 

10.   JTextField tf ; 

11.   JLabel lbl ; 

12.   JTextArea ta ; 

13.   JList lst ; 

14.   Container cp ; 

15.  

16.   public void 

17.   actionPerformed( ActionEvent ev ) 

18.   { 

19.     Font fnt, nwfnt ; 

20.  

21.     nwfnt = new Font ( "SansSerif", Font.PLAIN, 16 ); 

22.     tf.setFont ( nwfnt ) ; 

23.  

24.     nwfnt = new Font ( "Serif", Font.BOLD, 16 ); 

25.     lst.setFont ( nwfnt ) ; 

26.  

27.  

28.     fnt = lbl.getFont (); 

29.     nwfnt = new Font 

30.       ( "Serif", Font.ITALIC, fnt.getSize()+ 2 ) ; 

31.     lbl.setFont ( nwfnt ) ; 

32.  

33.     fnt = ta.getFont (); 

34.     nwfnt = new Font 

35.       ( fnt.getName(), 

36.         Font.ITALIC | Font.BOLD

37.         fnt.getSize()+ 1 ) ; 

38.     ta.setFont ( nwfnt ) ; 

39.  

40.     fnt = btn.getFont (); 

41.     nwfnt = new Font 

42.       ( fnt.getName(), Font.PLAIN, fnt.getSize()+ 3 ) ; 

43.     btn.setFont ( nwfnt ) ; 

44.   } 

45.   public 

46.   FontsSw ( ) 

47.   { 

48.     btn = new JButton ( "Look at me" ) ; 

49.     tf = new JTextField ( "Ha, ha, said the clown" ) ; 

50.     lbl = new JLabel ( "We are the champions" ) ; 

51.     ta = new JTextArea ( 5,20 ) ; 

52.     String[] vals = { "Virtual lingerie", "For everyone" } ; 

53.     lst = new JList ( vals ) ; 

54.   } 

55.   public void 

56.   init() 

57.   { 

58.     cp = getContentPane(); 

59.     cp.setLayout(new FlowLayout() ); 

60.     cp.add ( btn) ; 

61.     cp.add ( tf ) ; 

62.     cp.add ( lbl ) ; 

63.     ta.append ( "Better to burn up \nthan to fade away" ) ; 

64.     cp.add ( ta ) ; 

65.     cp.add ( lst ) ; 

66.      btn.addActionListener ( this ) ; 

67.   } 

68.

69. /*=======  Java Fonts :  ====== 

70.   Serif  ( Times

71.   SansSerif  ( Helvetica

72.   Monospaced  ( Courier

73.   DialogInput 

74.   Dialog 

75.   Symbol 

76. */ 

77.