/** * contrast with SimpleBean3. In SimpleBean4, we have given dumb() * and argument String s. Now the Beanbox does not recognize it. * More sophisiticated builder tools, such as Visual Age for Java * can handle such public methods with arguments. */ import java.awt.*; import java.io.Serializable; public class SimpleBean4 extends Canvas implements Serializable{ private Color color = Color.black; private String msg = "Hello, World"; //Constructor sets inherited properties public SimpleBean4(){ setSize(100,40); setBackground(Color.red); } public Color getColor() { return color; } public void setColor(Color c) { color = c; repaint(); } // You need both a setter and a getter to have the property // appear in the property sheet in the Beanbox public void setMsg(String msg) { this.msg = msg; } public String getMsg() { return msg; } public void dumb(String s) { setMsg(s); repaint(); } public void paint(Graphics g) { g.setColor(color); g.drawString(msg, 20, 20); } }