// MyLabel Bean Class // MyLabel.java import java.awt.*; import java.io.Serializable; public class MyLabel extends Canvas implements Serializable { // ----- insert label property declaration code here *** // Constructors public MyLabel() { // insert default constructor code here } public MyLabel(String l) { // insert single-argument constructor code here *** } // Accessor methods public String getLabel() { // insert getLabel() method code here *** } public void setLabel(String l) { // insert setLabel() method code here *** } // Other public methods public synchronized void paint(Graphics g) { int width = getSize().width; int height = getSize().height; // Paint the background g.setColor(getBackground()); g.fillRect(0, 0, width, height); // Paint the label (foreground) text g.setColor(getForeground()); g.setFont(getFont()); FontMetrics fm = g.getFontMetrics(); g.drawString(label, (width - fm.stringWidth(label)) / 2, (height + fm.getMaxAscent() - fm.getMaxDescent()) / 2); } }