/* 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. package ourbeans; 

2.  

3. import java.awt.*; 

4.  

5. public class Bitres  extends Canvas 

6.   implements java.io.Serializable 

7.

8.   private int thick = 1

9.  

10.   public int 

11.   getThick (){ 

12.     return thick ; 

13.   } 

14.   public void 

15.   setThick ( int t ) { 

16.     if ( t > 0 && t < 6

17.     { 

18.       thick = t ; 

19.       repaint(); 

20.     } 

21.   } 

22.   public Bitres() 

23.   { 

24.  

25.   } 

26.   public void 

27.   paint ( Graphics gr ) 

28.   { 

29.     String str = "I'm the 3d bean, am I not ?"

30.     FontMetrics fm = gr.getFontMetrics (); 

31.     int w = fm.stringWidth ( str ) ; 

32.  

33.     gr.drawString ( str, 20, 20 ) ; 

34.     for ( int i = 0 ; i <= thick ; i++ ) 

35.       gr.drawLine ( 20, 22 + i, 20 + w, 22 + i ); 

36.   } 

37.   public Dimension 

38.   getPreferredSize (){ 

39.     return new Dimension (200,150); 

40.   } 

41.   public Dimension 

42.   getMinimumSize (){ 

43.     return getPreferredSize (); 

44.   } 

45.