package flexlabel; import java.beans.*; import java.awt.*; public class LabelEditor extends PropertyEditorSupport { private String label; public void setValue(Object o) { label = (String) o; firePropertyChange(); } public Object getValue() { return label; } public boolean isPaintable() { return true; } public void paintValue(Graphics g, Rectangle box) { String str = "Edit Label..."; g.setColor(Color.white); g.fillRect(box.x, box.y, box.width, box.height); g.setColor(Color.black); FontMetrics fm = g.getFontMetrics(); int w = fm.stringWidth(str); int h = fm.getAscent() + fm.getDescent(); int x = ((box.width - w) / 2) + box.x; int y = ((box.height - h) / 2) + fm.getAscent() + box.y; g.drawString(str, x, y); } public boolean supportsCustomEditor() { return true; } public Component getCustomEditor() { return new LabelTextAreaPanel(this); } }