KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > data > TestVisualBean


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package data;
21
22 import java.awt.*;
23 import java.io.Serializable JavaDoc;
24
25 /**
26  * Simple visual javabean
27  *
28  * @author Jiri Vagner
29  */

30 public class TestVisualBean extends Canvas implements Serializable JavaDoc {
31     
32     private Color textColor = Color.blue;
33     private String JavaDoc text = "Lancia Lybra"; // NOI18N
34

35     /** Creates a new instance of VisualTestBean */
36     public TestVisualBean() {
37         resize(100,40);
38     }
39     
40     public void paint(Graphics g) {
41         g.setColor(Color.blue);
42         g.drawString(text,10, 10);
43     }
44     
45     /**
46      * Returns color value
47      * @return Color value
48      */

49     public Color getColor() {
50         return textColor;
51     }
52     
53     /**
54      * Sets new color
55      * @param newColor value
56      */

57     public void setColor(Color newColor) {
58         textColor = newColor;
59         repaint();
60     }
61     
62     /**
63      * Returns text
64      * @return text
65      */

66     public String JavaDoc getText() {
67         return text;
68     }
69     
70     /**
71      * Sets text value
72      * @param newText
73      */

74     public void setText(String JavaDoc newText) {
75         text = newText;
76         repaint();
77     }
78 }
Popular Tags