package com.jeromecompsci.dgui;

import javax.swing.*;

/**
 * @author Derek Wang
 */
public class TextField extends Widget implements TextBased {
    private JTextField field;

    public TextField() {
        this("");
    }
    public TextField(String initialText) {
        field = new JTextField();
        setSize(Widget.DEFAULT_WIDTH, Widget.DEFAULT_HEIGHT);
        setText(initialText);
    }

    @Override public String getText() {
        return field.getText();
    }

    @Override public void setText(String s) {
        field.setText(s);
    }

    @Override public JComponent getInternal() {
        return field;
    }
}

@@ -47,16 +47,83 @@
 swing.*;
+%0Aimport java.awt.event.KeyEvent;%0Aimport java.awt.event.KeyListener;
 %0A%0A/**%0A *
@@ -177,16 +177,24 @@
 extends 
+Bindable
 Widget i
@@ -621,32 +621,1196 @@
 Text(s);%0A    %7D%0A%0A
+    @Override void addBindingForEvent(String evt, Binding binding) %7B%0A        switch (evt) %7B%0A            case %22change%22:%0A                field.addKeyListener(new KeyListener() %7B%0A                    @Override%0A                    public void keyTyped(KeyEvent keyEvent) %7B%0A                        binding.executeBoundMethod();%0A                    %7D%0A%0A                    @Override public void keyPressed(KeyEvent keyEvent) %7B %7D%0A                    @Override public void keyReleased(KeyEvent keyEvent) %7B %7D%0A                %7D);%0A                break;%0A            case %22enter%22:%0A                field.addKeyListener(new KeyListener() %7B%0A                    @Override public void keyTyped(KeyEvent keyEvent) %7B %7D%0A                    @Override public void keyPressed(KeyEvent keyEvent) %7B %7D%0A%0A                    @Override public void keyReleased(KeyEvent keyEvent) %7B%0A                        if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) %7B%0A                            binding.executeBoundMethod();%0A                        %7D%0A                    %7D%0A                %7D);%0A                break;%0A            default:%0A                throw new NoSuchEventException(evt);%0A        %7D%0A    %7D%0A%0A
     @Override pu
@@ -1869,10 +1869,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Make TextField a BindableWidget with two events: 'change' and 'enter', so clients can pick up on when a user changes the text in a TextField or when they press Enter/Return