1 package org.johndavidtaylor.beans.beanpeeler;
2 import java.awt.Color;
3 import java.awt.Font;
4 import java.awt.Label;
5 import java.beans.PropertyChangeListener;
6 import java.beans.PropertyChangeSupport;
7 public class TestBean extends Label {
8 private PropertyChangeSupport changes =
9 new PropertyChangeSupport(this);
10
11 public void addPropertyChangeListener(
12 PropertyChangeListener l)
13 {
14 changes.addPropertyChangeListener(l);
15 }
16 public void removePropertyChangeListener(
17 PropertyChangeListener l)
18 {
19 changes.removePropertyChangeListener(l);
20 }
21
22
23 /*** Holds value of property font. */
24 private Font font;
25
26 public TestBean(String s) {
27 super(s);
28
29 setBackground(Color.black);
30 setForeground(Color.red);
31 }
32
33 /*** Getter for property fontSize.
34 * @return Value of property fontSize.
35 */
36 public int getFontSize() {
37 return getFont().getSize();
38 }
39
40 /*** Setter for property fontSize.
41 * @param fontSize New value of property fontSize.
42 */
43 public void setFontSize(int fontSize) {
44
45 Font f = getFont();
46 Font f2 = new Font(f.getName(),f.getStyle(),fontSize);
47 setFont(f2);
48 }
49
50 /*** Getter for property bold.
51 * @return Value of property bold.
52 */
53 public boolean isBold() {
54 return getFont().getStyle()==Font.BOLD;
55 }
56
57 /*** Setter for property bold.
58 * @param bold New value of property bold.
59 */
60 public void setBold(boolean bold) {
61 Font f = getFont();
62 int style = bold? Font.BOLD : Font.PLAIN;
63 Font f2 = new Font(f.getName(),style,f.getSize());
64 setFont(f2);
65 }
66
67 /*** Getter for property text.
68 * @return Value of property text.
69 */
70 public String getText() {
71 return super.getText();
72 }
73
74 /*** Setter for property text.
75 * @param text New value of property text.
76 */
77 public void setText(String text) {
78 Object old = getText();
79 super.setText(text);
80 changes.firePropertyChange("text", old, text);
81 }
82
83 /*** Getter for property background.
84 * @return Value of property background.
85 */
86 public Color getBackground() {
87 return super.getBackground();
88 }
89
90 /*** Setter for property background.
91 * @param background New value of property background.
92 */
93 public void setBackground(Color background) {
94 Object old = getBackground();
95 super.setBackground(background);
96 changes.firePropertyChange("background", old, background);
97 }
98
99 /*** Getter for property foreground.
100 * @return Value of property foreground.
101 */
102 public Color getForeground() {
103 return super.getForeground();
104 }
105
106 /*** Setter for property foreground.
107 * @param foreground New value of property foreground.
108 */
109 public void setForeground(Color foreground) {
110 Object old = getForeground();
111 super.setForeground(foreground);
112 changes.firePropertyChange("foreground", old, foreground);
113 }
114
115 /*** Getter for property font.
116 * @return Value of property font.
117 */
118 public Font getFont() {
119 return super.getFont();
120 }
121
122 /*** Setter for property font.
123 * @param font New value of property font.
124 */
125 public void setFont(Font font) {
126 Object old = getFont();
127 super.setFont(font);
128 changes.firePropertyChange("font", old, font);
129 }
130
131 }
132
This page was automatically generated by Maven