Extending by Delegation

XMLTextField extends
JTextField
+ getText() : String
+ getMaximumSize() : Dimension
+ getMinimumSize() : Dimension
+ getPreferredSize() : Dimension
and implements
XMLDataWidget
+ loadData(ScriptExecutionContext)
+ saveData(ScriptExecutionContext)
and
XMLDataValidator
+ validateData() : boolean
XMLTextField delegates to
XMLTextDelegate
parseTextElement(Node) : String
loadsData() : boolean
loadData(ScriptExecutionContext) : String
validateText(Component, String) : boolean
saveData(ScriptExecutionContext, String)
adjustSize(Dimension) : Dimension
class XMLTextField extends JTextField 
                   implements XMLDataWidget, XMLDataValidator {
    private XMLTextDelegate delegate;

    XMLTextField(Node textNode, String multiKey) {
        delegate = new XMLTextDelegate( textNode, multiKey );
        String text = delegate.parseTextElement(textNode);
        if (text != null) {
            setText(text.trim());
        }
        addFocusListener(new FocusAdapter() {
            public void focusGained(FocusEvent event) {
                if (!event.isTemporary()) { selectAll(); }
            }
        });
    }

    public void loadData(ScriptExecutionContext context) {
        if (delegate.loadsData()) {
            setText(delegate.loadData(context));
        }                                   
    }

    public boolean validateData() {
        return delegate.validateText(this, getText());
    }

    public void saveData(ScriptExecutionContext context) {
        delegate.saveData(context, getText());
    }

    public Dimension getMinimumSize() {
        return delegate.adjustSize(super.getMinimumSize());
    }
    public Dimension getPreferredSize() {
        return delegate.adjustSize(super.getPreferredSize());
    }
    public Dimension getMaximumSize() {
        return delegate.adjustSize(super.getMaximumSize());
    }
}