- Timestamp:
- 09/23/13 18:54:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/gui/controls/TextFieldControl.java
r101 r107 3 3 import com.framsticks.gui.Gui; 4 4 import com.framsticks.params.PrimitiveParam; 5 import com.framsticks.util.lang.Strings;6 5 7 6 import javax.swing.*; 7 import javax.swing.text.JTextComponent; 8 8 9 import java.awt.*; 9 10 10 11 @SuppressWarnings("serial") 11 public class TextFieldControl extends Text Control {12 public class TextFieldControl extends TextOnlyControl { 12 13 13 14 14 private static final Color CORRECT_COLOR = new Color(180, 255, 215);15 15 private static final Color WRONG_COLOR = new Color(255, 180, 215); 16 16 17 17 protected final JTextField textField; 18 private final Color correctColor; 18 19 19 20 @Override 20 21 protected boolean notifyOfChange() { 21 22 boolean result = super.notifyOfChange(); 22 textField.setBackground(result ? CORRECT_COLOR: WRONG_COLOR);23 textField.setBackground(result ? correctColor : WRONG_COLOR); 23 24 return result; 24 25 } … … 28 29 textField = new JTextField(); 29 30 textField.setName("value"); 31 correctColor = textField.getBackground(); 30 32 31 33 textField.setMinimumSize(new Dimension(0, Control.LINE_HEIGHT)); … … 37 39 } 38 40 39 @Override40 public void pushValueToUserInterfaceImpl(Object text) {41 textField.setText(Strings.toStringNullProof(text));42 }43 41 44 42 @Override 45 p ublic Object pullValueFromUserInterface() {46 return textField .getText();43 protected JTextComponent getTextComponent() { 44 return textField; 47 45 } 48 46
Note: See TracChangeset
for help on using the changeset viewer.