Browse Source

Make ValidatingTextField extend JTextField

Change-Id: I30ca8bc84a18cc67a9bcb3700a9b15307e389bc2
Reviewed-on: http://gerrit.dmdirc.com/3066
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 years ago
parent
commit
fb4ff22e87

+ 1
- 1
src/com/dmdirc/addons/serverlistdialog/AddEntryInputDialog.java View File

@@ -122,7 +122,7 @@ public class AddEntryInputDialog extends StandardDialog {
122 122
     private void initComponents(final IconManager iconManager) {
123 123
         orderButtons(new JButton(), new JButton());
124 124
         entryName = new ValidatingJTextField(iconManager, entryValidator);
125
-        uri = new ValidatingJTextField(iconManager, new URIJTextField(), uriValidator);
125
+        uri = new URIJTextField(iconManager, "", uriValidator);
126 126
         blurb = new TextLabel(message);
127 127
         validateText();
128 128
     }

+ 10
- 9
src/com/dmdirc/addons/serverlistdialog/URIJTextField.java View File

@@ -21,23 +21,24 @@
21 21
  */
22 22
 package com.dmdirc.addons.serverlistdialog;
23 23
 
24
-import javax.swing.JTextField;
24
+import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
25
+import com.dmdirc.ui.IconManager;
26
+import com.dmdirc.util.validators.Validator;
25 27
 
26 28
 /**
27 29
  * Simple extention of JTextField to return an URI usable string (defaulting to
28 30
  * an irc scheme if none specified).
29 31
  */
30
-public class URIJTextField extends JTextField {
32
+public class URIJTextField extends ValidatingJTextField {
31 33
 
32
-    /**
33
-     * A version number for this class. It should be changed whenever
34
-     * the class structure is changed (or anything else that would
35
-     * prevent serialized objects being unserialized with the new
36
-     * class).
37
-     */
34
+    /** A version number for this class. */
38 35
     private static final long serialVersionUID = 1;
39 36
 
40
-    /** {@inheritDoc} */
37
+    public URIJTextField(final IconManager iconManager, final String text,
38
+            final Validator<String> validator) {
39
+        super(iconManager, text, validator);
40
+    }
41
+
41 42
     @Override
42 43
     public String getText() {
43 44
         final String hostname = super.getText();

+ 2
- 8
src/com/dmdirc/addons/ui_swing/components/FileBrowser.java View File

@@ -34,7 +34,6 @@ import java.awt.event.KeyListener;
34 34
 import javax.swing.JButton;
35 35
 import javax.swing.JFileChooser;
36 36
 import javax.swing.JPanel;
37
-import javax.swing.JTextField;
38 37
 
39 38
 import net.miginfocom.swing.MigLayout;
40 39
 
@@ -45,11 +44,7 @@ import net.miginfocom.swing.MigLayout;
45 44
  */
46 45
 public class FileBrowser extends JPanel implements ActionListener {
47 46
 
48
-    /**
49
-     * A version number for this class. It should be changed whenever the class
50
-     * structure is changed (or anything else that would prevent serialized
51
-     * objects being unserialized with the new class).
52
-     */
47
+    /** A version number for this class. */
53 48
     private static final long serialVersionUID = 1;
54 49
     /** Text field to show path of chosen file. */
55 50
     private final ValidatingJTextField pathField;
@@ -74,8 +69,7 @@ public class FileBrowser extends JPanel implements ActionListener {
74 69
         final JButton browseButton = new JButton("Browse");
75 70
         browseButton.addActionListener(this);
76 71
 
77
-        pathField = new ValidatingJTextField(iconManager,
78
-                new JTextField(setting.getValue()), setting.getValidator());
72
+        pathField = new ValidatingJTextField(iconManager, setting.getValue(), setting.getValidator());
79 73
 
80 74
         setLayout(new MigLayout("ins 0, fill"));
81 75
         add(pathField, "growx, pushx, sgy all");

+ 87
- 0
src/com/dmdirc/addons/ui_swing/components/JIconTextField.java View File

@@ -0,0 +1,87 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+package com.dmdirc.addons.ui_swing.components;
23
+
24
+import java.awt.Graphics;
25
+import java.awt.Insets;
26
+import java.awt.event.MouseEvent;
27
+
28
+import javax.swing.Icon;
29
+import javax.swing.JTextField;
30
+import javax.swing.ToolTipManager;
31
+import javax.swing.UIManager;
32
+
33
+/**
34
+ * JTextfield capable of displaying an icon and tooltip.
35
+ */
36
+public class JIconTextField extends JTextField {
37
+
38
+    /** Insets used by a normal text field. */
39
+    private final Insets dummyInsets;
40
+    /** Icon to show, or null. */
41
+    private Icon icon;
42
+    /** Message to show, or null. */
43
+    private String message;
44
+
45
+    public JIconTextField() {
46
+        super();
47
+        this.icon = null;
48
+        this.dummyInsets = UIManager.getBorder("TextField.border").getBorderInsets(new JTextField());
49
+        ToolTipManager.sharedInstance().registerComponent(this);
50
+    }
51
+
52
+    public void setIcon(final Icon icon) {
53
+        this.icon = icon;
54
+    }
55
+
56
+    public Icon getIcon() {
57
+        return icon;
58
+    }
59
+
60
+    public void setMessage(final String message) {
61
+        this.message = message;
62
+    }
63
+
64
+    public String getMessage() {
65
+        return message;
66
+    }
67
+
68
+    @Override
69
+    protected void paintComponent(final Graphics g) {
70
+        super.paintComponent(g);
71
+        if (this.icon != null) {
72
+            final int x = getWidth() - dummyInsets.right - icon.getIconWidth();
73
+            setMargin(new Insets(2, 2, 2, getWidth() - x));
74
+            icon.paintIcon(this, g, x, ((getHeight() - icon.getIconHeight()) / 2));
75
+        } else {
76
+            setMargin(new Insets(2, 2, 2, 2));
77
+        }
78
+    }
79
+
80
+    @Override
81
+    public String getToolTipText(final MouseEvent event) {
82
+        if (icon != null && (event.getX() >= getWidth() - dummyInsets.right - dummyInsets.right - icon.getIconWidth())) {
83
+            return message;
84
+        }
85
+        return super.getToolTipText(event);
86
+    }
87
+}

+ 2
- 2
src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java View File

@@ -276,7 +276,7 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
276 276
      * @return Search textfield
277 277
      */
278 278
     public JTextField getTextField() {
279
-        return searchBox.getTextField();
279
+        return searchBox;
280 280
     }
281 281
 
282 282
     /**
@@ -286,7 +286,7 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
286 286
      */
287 287
     @Override
288 288
     public void keyPressed(final KeyEvent event) {
289
-        if (event.getSource() == searchBox.getTextField()) {
289
+        if (event.getSource() == searchBox) {
290 290
             if (event.getKeyCode() == KeyEvent.VK_ESCAPE) {
291 291
                 close();
292 292
             } else if (event.getKeyCode() == KeyEvent.VK_ENTER) {

+ 4
- 18
src/com/dmdirc/addons/ui_swing/components/inputfields/ValidatingTextFieldInputField.java View File

@@ -31,7 +31,6 @@ import com.dmdirc.util.validators.Validator;
31 31
 import java.awt.event.ActionEvent;
32 32
 import java.awt.event.ActionListener;
33 33
 
34
-import javax.swing.JTextField;
35 34
 import javax.swing.text.BadLocationException;
36 35
 
37 36
 /**
@@ -55,7 +54,7 @@ public class ValidatingTextFieldInputField extends ValidatingJTextField
55 54
      */
56 55
     public ValidatingTextFieldInputField(final SwingController controller,
57 56
             final Validator<String> validator) {
58
-        this(controller, new JTextField(), validator);
57
+        this(controller, "", validator);
59 58
     }
60 59
 
61 60
     /**
@@ -63,11 +62,11 @@ public class ValidatingTextFieldInputField extends ValidatingJTextField
63 62
      *
64 63
      * @param controller Swing controller
65 64
      * @param validator Validator for this textfield
66
-     * @param textField Textfield to use as a base
65
+     * @param text Text to use
67 66
      */
68 67
     public ValidatingTextFieldInputField(final SwingController controller,
69
-            final JTextField textField, final Validator<String> validator) {
70
-        super(controller.getIconManager(), textField, validator);
68
+            final String text, final Validator<String> validator) {
69
+        super(controller.getIconManager(), text, validator);
71 70
         this.controller = controller;
72 71
     }
73 72
 
@@ -119,17 +118,4 @@ public class ValidatingTextFieldInputField extends ValidatingJTextField
119 118
             colourPicker = null;
120 119
         }
121 120
     }
122
-
123
-    /** {@inheritDoc} */
124
-    @Override
125
-    public int getCaretPosition() {
126
-        return getTextField().getCaretPosition();
127
-    }
128
-
129
-    /** {@inheritDoc} */
130
-    @Override
131
-    public void setCaretPosition(final int position) {
132
-        getTextField().setCaretPosition(position);
133
-    }
134
-
135 121
 }

+ 34
- 394
src/com/dmdirc/addons/ui_swing/components/validating/ValidatingJTextField.java View File

@@ -22,45 +22,30 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.validating;
24 24
 
25
-import com.dmdirc.addons.ui_swing.UIUtilities;
25
+import com.dmdirc.addons.ui_swing.components.JIconTextField;
26 26
 import com.dmdirc.ui.IconManager;
27 27
 import com.dmdirc.util.validators.ValidationResponse;
28 28
 import com.dmdirc.util.validators.Validator;
29 29
 
30
-import java.awt.Color;
31
-import java.awt.Font;
32
-import java.awt.event.KeyListener;
33
-import java.awt.event.MouseListener;
30
+import java.awt.Image;
31
+import java.awt.Insets;
34 32
 
35
-import javax.swing.Icon;
36
-import javax.swing.JComponent;
37
-import javax.swing.JLabel;
38
-import javax.swing.JTextField;
39
-import javax.swing.TransferHandler;
33
+import javax.swing.ImageIcon;
40 34
 import javax.swing.event.DocumentEvent;
41 35
 import javax.swing.event.DocumentListener;
42
-import javax.swing.text.BadLocationException;
43
-import javax.swing.text.Document;
44 36
 
45
-import net.miginfocom.swing.MigLayout;
46 37
 
47 38
 /**
48 39
  * Validating Text field.
49 40
  */
50
-public class ValidatingJTextField extends JComponent implements DocumentListener {
41
+public class ValidatingJTextField extends JIconTextField implements DocumentListener {
51 42
 
52
-    /**
53
-     * A version number for this class. It should be changed whenever the class
54
-     * structure is changed (or anything else that would prevent serialized
55
-     * objects being unserialized with the new class).
56
-     */
57
-    private static final long serialVersionUID = 1;
58
-    /** TextField. */
59
-    private final JTextField textField;
43
+    /** A version number for this class. */
44
+    private static final long serialVersionUID = 2;
60 45
     /** Validator. */
61 46
     private Validator<String> validator;
62
-    /** Error icon. */
63
-    private final JLabel errorIcon;
47
+    /** Error image. */
48
+    private final ImageIcon errorIcon;
64 49
 
65 50
     /**
66 51
      * Instantiates a new Validating text field.
@@ -70,41 +55,39 @@ public class ValidatingJTextField extends JComponent implements DocumentListener
70 55
      */
71 56
     public ValidatingJTextField(final IconManager iconManager,
72 57
             final Validator<String> validator) {
73
-        this(iconManager, new JTextField(), validator);
58
+        this(iconManager.getImage("input-error"), "", validator);
74 59
     }
60
+
75 61
     /**
76 62
      * Instantiates a new Validating text field.
77 63
      *
78 64
      * @param iconManager Icon manager
79
-     * @param textField JTextField to wrap
65
+     * @param text Text to display in textfield
80 66
      * @param validator Validator instance
81 67
      */
82
-    public ValidatingJTextField(final IconManager iconManager,
83
-            final JTextField textField, final Validator<String> validator) {
84
-        this(iconManager.getIcon("input-error"), textField, validator);
68
+    public ValidatingJTextField(final IconManager iconManager, final String text,
69
+            final Validator<String> validator) {
70
+        this(iconManager.getImage("input-error"), text, validator);
85 71
     }
86 72
 
87 73
     /**
88 74
      * Instantiates a new Validating text field.
89 75
      *
90 76
      * @param icon Icon to show on error
91
-     * @param textField JTextField to wrap
77
+     * @param text Text to display in textfield
92 78
      * @param validator Validator instance
93 79
      */
94
-    public ValidatingJTextField(final Icon icon,
95
-            final JTextField textField, final Validator<String> validator) {
80
+    public ValidatingJTextField(final Image icon, final String text, final Validator<String> validator) {
96 81
         super();
97
-        this.textField = textField;
98 82
         this.validator = validator;
99
-        errorIcon = new JLabel(icon);
83
+        errorIcon = new ImageIcon(icon);
84
+        setText(text);
100 85
 
101
-        setLayout(new MigLayout("fill, ins 0, hidemode 3, gap 0"));
102
-        add(textField, "grow, pushx");
103
-        add(errorIcon);
86
+        setMargin(new Insets(0, 0, 0, errorIcon.getIconWidth()));
104 87
 
105 88
         checkError();
106 89
 
107
-        textField.getDocument().addDocumentListener(this);
90
+        getDocument().addDocumentListener(this);
108 91
     }
109 92
 
110 93
     /**
@@ -121,15 +104,19 @@ public class ValidatingJTextField extends JComponent implements DocumentListener
121 104
      * Checks the text for errors and sets the error state accordingly.
122 105
      */
123 106
     public void checkError() {
124
-        if (textField.isEnabled()) {
125
-            final ValidationResponse vr =
126
-                    validator.validate(textField.getText());
127
-            errorIcon.setToolTipText(vr.getFailureReason());
128
-            firePropertyChange("validationResult", !errorIcon.isVisible(), !vr.isFailure());
129
-            errorIcon.setVisible(vr.isFailure());
107
+        if (isEnabled()) {
108
+            final ValidationResponse vr = validator.validate(getText());
109
+            setMessage(vr.getFailureReason());
110
+            firePropertyChange("validationResult", getMessage() != null, !vr.isFailure());
111
+            if (vr.isFailure()) {
112
+                setIcon(errorIcon);
113
+            } else {
114
+                setIcon(null);
115
+            }
130 116
         } else {
131
-            firePropertyChange("validationResult", !errorIcon.isVisible(), true);
132
-            errorIcon.setVisible(false);
117
+            setIcon(null);
118
+            setMessage(null);
119
+            firePropertyChange("validationResult", !getMessage().isEmpty(), true);
133 120
         }
134 121
     }
135 122
 
@@ -141,7 +128,7 @@ public class ValidatingJTextField extends JComponent implements DocumentListener
141 128
      * @return true iif the text validates
142 129
      */
143 130
     public boolean validateText() {
144
-        if (textField.isEnabled()) {
131
+        if (isEnabled()) {
145 132
             return !validator.validate(getText()).isFailure();
146 133
         } else {
147 134
             return true;
@@ -165,351 +152,4 @@ public class ValidatingJTextField extends JComponent implements DocumentListener
165 152
     public void removeUpdate(final DocumentEvent e) {
166 153
         checkError();
167 154
     }
168
-
169
-    /** {@inheritDoc} */
170
-    @Override
171
-    public void setToolTipText(final String text) {
172
-        textField.setToolTipText(text);
173
-    }
174
-
175
-    /** {@inheritDoc} */
176
-    @Override
177
-    public void setEnabled(final boolean enabled) {
178
-        textField.setEnabled(enabled);
179
-        checkError();
180
-    }
181
-
182
-    /** {@inheritDoc} */
183
-    @Override
184
-    public void requestFocus() {
185
-        textField.requestFocus();
186
-    }
187
-
188
-    /** {@inheritDoc} */
189
-    @Override
190
-    public boolean requestFocusInWindow() {
191
-        return textField.requestFocusInWindow();
192
-    }
193
-
194
-    /**
195
-     * Sets the text in the textfield.
196
-     *
197
-     * @see javax.swing.JTextField#setText(String)
198
-     *
199
-     * @param t Text to set
200
-     */
201
-    public void setText(final String t) {
202
-        textField.setText(t);
203
-    }
204
-
205
-    /**
206
-     * Sets the selection start.
207
-     *
208
-     * @see javax.swing.JTextField#setSelectionStart(int)
209
-     *
210
-     * @param selectionStart Start of the selection
211
-     */
212
-    public void setSelectionStart(final int selectionStart) {
213
-        textField.setSelectionStart(selectionStart);
214
-    }
215
-
216
-    /**
217
-     * Sets the selection end.
218
-     *
219
-     * @see javax.swing.JTextField#setSelectionEnd(int)
220
-     *
221
-     * @param selectionEnd End of the selection
222
-     */
223
-    public void setSelectionEnd(final int selectionEnd) {
224
-        textField.setSelectionEnd(selectionEnd);
225
-    }
226
-
227
-    /**
228
-     * Sets whether the component is editable.
229
-     *
230
-     * @see javax.swing.JTextField#setEditable(boolean)
231
-     *
232
-     * @param b editable state for the component
233
-     */
234
-    public void setEditable(final boolean b) {
235
-        textField.setEditable(b);
236
-    }
237
-
238
-    /**
239
-     * Selects all text in the textfield.
240
-     *
241
-     * @see javax.swing.JTextField#selectAll()
242
-     */
243
-    public void selectAll() {
244
-        textField.selectAll();
245
-    }
246
-
247
-    /**
248
-     * Selects the specified text in the textfield.
249
-     *
250
-     * @see javax.swing.JTextField#select(int, int)
251
-     *
252
-     * @param selectionStart Selection start
253
-     * @param selectionEnd Selection end
254
-     */
255
-    public void select(final int selectionStart, final int selectionEnd) {
256
-        textField.select(selectionStart, selectionEnd);
257
-    }
258
-
259
-    /**
260
-     * Replaces the textfields selection with the specified content.
261
-     *
262
-     * @see javax.swing.JTextField#replaceSelection(String)
263
-     *
264
-     * @param content Text to replace selection with
265
-     */
266
-    public void replaceSelection(final String content) {
267
-        textField.replaceSelection(content);
268
-    }
269
-
270
-    /**
271
-     * Paste's the system clipboard into the textfield.
272
-     *
273
-     * @see javax.swing.JTextField#paste()
274
-     */
275
-    public void paste() {
276
-        textField.paste();
277
-    }
278
-
279
-    /**
280
-     * Checks if the textfield is editable.
281
-     *
282
-     * @see javax.swing.JTextField#isEditable()
283
-     *
284
-     * @return true iif the textfield is editable
285
-     */
286
-    public boolean isEditable() {
287
-        return textField.isEditable();
288
-    }
289
-
290
-    /**
291
-     * Returns the text in the textfield.
292
-     *
293
-     * @see javax.swing.JTextField#getText()
294
-     *
295
-     * @return Textfield content
296
-     */
297
-    public String getText() {
298
-        return textField.getText();
299
-    }
300
-
301
-    /**
302
-     * Returns the specified section of text in the textfield.
303
-     *
304
-     * @see javax.swing.JTextField#getText(int, int)
305
-     *
306
-     * @param offs Start offset
307
-     * @param len section length
308
-     *
309
-     * @return Specified textfield content
310
-     *
311
-     * @throws javax.swing.text.BadLocationException if the bounds are wrong
312
-     */
313
-    public String getText(final int offs, final int len) throws BadLocationException {
314
-        return textField.getText(offs, len);
315
-    }
316
-
317
-    /**
318
-     * Returns the start of the selection in the textfield.
319
-     *
320
-     * @see javax.swing.JTextField#getSelectionStart()
321
-     *
322
-     * @return Selection start
323
-     */
324
-    public int getSelectionStart() {
325
-        return textField.getSelectionStart();
326
-    }
327
-
328
-    /**
329
-     * Returns the end of the textfield selection.
330
-     *
331
-     * @see javax.swing.JTextField#getSelectionEnd()
332
-     *
333
-     * @return Selection end
334
-     */
335
-    public int getSelectionEnd() {
336
-        return textField.getSelectionEnd();
337
-    }
338
-
339
-    /**
340
-     * Returns the selected text in the textfield.
341
-     *
342
-     * @see javax.swing.JTextField#getSelectedText()
343
-     *
344
-     * @return Selected text
345
-     */
346
-    public String getSelectedText() {
347
-        return textField.getSelectedText();
348
-    }
349
-
350
-    /**
351
-     * Returns the textfield's document.
352
-     *
353
-     * @see javax.swing.JTextField#getDocument()
354
-     *
355
-     * @return Textfield's document
356
-     */
357
-    public Document getDocument() {
358
-        return textField.getDocument();
359
-    }
360
-
361
-    /**
362
-     * Cuts the selected text from the textfield into the clipboard.
363
-     *
364
-     * @see javax.swing.JTextField#cut()
365
-     */
366
-    public void cut() {
367
-        textField.cut();
368
-    }
369
-
370
-    /**
371
-     * Copies the selected text from the textfield into the clipboard.
372
-     *
373
-     * @see javax.swing.JTextField#copy()
374
-     */
375
-    public void copy() {
376
-        textField.copy();
377
-    }
378
-
379
-    /**
380
-     * Returns the font for the textfield.
381
-     *
382
-     * @see javax.swing.JTextField#copy()
383
-     */
384
-    @Override
385
-    public Font getFont() {
386
-        return textField.getFont();
387
-    }
388
-
389
-    /** {@inheritDoc} */
390
-    @Override
391
-    public synchronized void addKeyListener(final KeyListener l) {
392
-        textField.addKeyListener(l);
393
-    }
394
-
395
-    /** {@inheritDoc} */
396
-    @Override
397
-    public synchronized void removeKeyListener(final KeyListener l) {
398
-        textField.removeKeyListener(l);
399
-    }
400
-
401
-    /** {@inheritDoc} */
402
-    @Override
403
-    public synchronized void addMouseListener(final MouseListener l) {
404
-        textField.addMouseListener(l);
405
-    }
406
-
407
-    /** {@inheritDoc} */
408
-    @Override
409
-    public synchronized void removeMouseListener(final MouseListener l) {
410
-        textField.removeMouseListener(l);
411
-    }
412
-
413
-    /**
414
-     * Sets the drag enabled property on the textfield.
415
-     *
416
-     * @param enabled Enabled?
417
-     */
418
-    public void setDragEnabled(final boolean enabled) {
419
-        textField.setDragEnabled(enabled);
420
-    }
421
-
422
-    /** {@inheritDoc} */
423
-    @Override
424
-    public void setTransferHandler(final TransferHandler newHandler) {
425
-        textField.setTransferHandler(newHandler);
426
-    }
427
-
428
-    /**
429
-     * Returns the validator used by this text field.
430
-     *
431
-     * @since 0.6.3m1
432
-     *
433
-     * @return This field's validator
434
-     */
435
-    public Validator<String> getValidator() {
436
-        return validator;
437
-    }
438
-
439
-    /**
440
-     * Returns the text field used by this validating text field.
441
-     *
442
-     * @since 0.6.3m1
443
-     *
444
-     * @return This field's text field
445
-     */
446
-    public JTextField getTextField() {
447
-        return textField;
448
-    }
449
-
450
-    /**
451
-     * Sets the caret colour to the specified coloour.
452
-     *
453
-     * @param optionColour Colour for the caret
454
-     */
455
-    public void setCaretColor(final Color optionColour) {
456
-        UIUtilities.invokeLater(new Runnable() {
457
-
458
-            /** {@inheritDoc} */
459
-            @Override
460
-            public void run() {
461
-                textField.setCaretColor(optionColour);
462
-            }
463
-        });
464
-    }
465
-
466
-    /**
467
-     * Sets the foreground colour to the specified coloour.
468
-     *
469
-     * @param optionColour Colour for the foreground
470
-     */
471
-    @Override
472
-    public void setForeground(final Color optionColour) {
473
-        UIUtilities.invokeLater(new Runnable() {
474
-
475
-            /** {@inheritDoc} */
476
-            @Override
477
-            public void run() {
478
-                textField.setForeground(optionColour);
479
-            }
480
-        });
481
-    }
482
-
483
-    /**
484
-     * Sets the disabled text colour to the specified coloour.
485
-     *
486
-     * @param optionColour Colour for the disabled text
487
-     */
488
-    public void setDisabledTextColour(final Color optionColour) {
489
-        UIUtilities.invokeLater(new Runnable() {
490
-
491
-            /** {@inheritDoc} */
492
-            @Override
493
-            public void run() {
494
-                textField.setDisabledTextColor(optionColour);
495
-            }
496
-        });
497
-    }
498
-
499
-    /**
500
-     * Sets the background colour to the specified coloour.
501
-     *
502
-     * @param optionColour Colour for the caret
503
-     */
504
-    @Override
505
-    public void setBackground(final Color optionColour) {
506
-        UIUtilities.invokeLater(new Runnable() {
507
-
508
-            /** {@inheritDoc} */
509
-            @Override
510
-            public void run() {
511
-                textField.setBackground(optionColour);
512
-            }
513
-        });
514
-    }
515 155
 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionNamePanel.java View File

@@ -122,7 +122,7 @@ public class ActionNamePanel extends JPanel implements PropertyChangeListener {
122 122
     @SuppressWarnings("unchecked")
123 123
     private void initComponents() {
124 124
         name = new ValidatingJTextField(iconManager,
125
-                new JTextField(existingName),
125
+                existingName,
126 126
                 new ValidatorChain<>(new FileNameValidator(),
127 127
                 new ActionNameValidator(group, existingName)));
128 128
     }

Loading…
Cancel
Save