| 34 | import org.microemu.device.ui.TextFieldUI; |
| 35 | |
| 36 | public class TextField extends Item { |
| 37 | |
| 38 | public static final int ANY = 0; |
| 39 | public static final int EMAILADDR = 1; |
| 40 | public static final int NUMERIC = 2; |
| 41 | public static final int PHONENUMBER = 3; |
| 42 | public static final int URL = 4; |
| 43 | public static final int DECIMAL = 5; |
| 44 | public static final int PASSWORD = 0x10000; |
| 45 | public static final int UNEDITABLE = 0x20000; |
| 46 | public static final int SENSITIVE = 0x40000; |
| 47 | public static final int NON_PREDICTIVE = 0x80000; |
| 48 | public static final int INITIAL_CAPS_WORD = 0x100000; |
| 49 | public static final int INITIAL_CAPS_SENTENCE = 0x200000; |
| 50 | public static final int CONSTRAINT_MASK = 0xffff; |
| 51 | StringComponent stringComponent; |
| 52 | private String field; |
| 53 | private int caret; |
| 54 | private boolean caretVisible; |
| 55 | private int maxSize; |
| 56 | private int constraints; |
| 57 | private InputMethodListener inputMethodListener = new InputMethodListener() { |
| 58 | |
| 59 | public void caretPositionChanged(InputMethodEvent event) { |
| 60 | setCaretPosition(event.getCaret()); |
| 61 | setCaretVisible(true); |
| 62 | repaint(); |
| 63 | } |
| 64 | |
| 65 | public void inputMethodTextChanged(InputMethodEvent event) { |
| 66 | setCaretVisible(false); |
| 67 | setString(event.getText(), event.getCaret()); |
| 68 | repaint(); |
| 69 | } |
| 70 | |
| 71 | public int getCaretPosition() { |
| 72 | return TextField.this.getCaretPosition(); |
| 73 | } |
| 74 | |
| 75 | public String getText() { |
| 76 | return TextField.this.getString(); |
| 77 | } |
| 78 | |
| 79 | public int getConstraints() { |
| 80 | return TextField.this.getConstraints(); |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | public TextField(String label, String text, int maxSize, int constraints) { |
| 85 | super(label); |
| 86 | super.setUI(DeviceFactory.getDevice().getUIFactory().createTextFieldUI(this)); |
| 87 | |
| 88 | if (maxSize <= 0) { |
| 89 | throw new IllegalArgumentException(); |
| 90 | } |
| 91 | setConstraints(constraints); |
| 92 | if (!InputMethod.validate(text, constraints)) { |
| 93 | throw new IllegalArgumentException(); |
nothing calls this directly
no outgoing calls
no test coverage detected