87 |
throws BadLocationException |
throws BadLocationException |
88 |
{ |
{ |
89 |
super.remove(bypass, offset, length); |
super.remove(bypass, offset, length); |
90 |
|
checkValidInput(); |
91 |
commitIfAllowed(); |
commitIfAllowed(); |
92 |
} |
} |
93 |
|
|
106 |
String text, AttributeSet attributes) |
String text, AttributeSet attributes) |
107 |
throws BadLocationException |
throws BadLocationException |
108 |
{ |
{ |
109 |
super.insertString(bypass, offset, text, attributes); |
if (overwriteMode == true) |
110 |
|
replace(bypass, offset, text.length(), text, attributes); |
111 |
|
else |
112 |
|
super.insertString(bypass, offset, text, attributes); |
113 |
|
checkValidInput(); |
114 |
commitIfAllowed(); |
commitIfAllowed(); |
115 |
} |
} |
116 |
|
|
131 |
throws BadLocationException |
throws BadLocationException |
132 |
{ |
{ |
133 |
super.replace(bypass, offset, length, text, attributes); |
super.replace(bypass, offset, length, text, attributes); |
134 |
|
checkValidInput(); |
135 |
commitIfAllowed(); |
commitIfAllowed(); |
136 |
} |
} |
137 |
|
|
151 |
// ignore invalid edits |
// ignore invalid edits |
152 |
} |
} |
153 |
} |
} |
154 |
|
|
155 |
|
/** |
156 |
|
* Checks if the value in the input field is valid. If the |
157 |
|
* property allowsInvalid is set to <code>false</code>, then |
158 |
|
* the string in the input field is not allowed to be entered. |
159 |
|
* |
160 |
|
* @param doc the document of the input field |
161 |
|
* @param value the current (old) value of the input field |
162 |
|
*/ |
163 |
|
private void checkValidInput() |
164 |
|
{ |
165 |
|
JFormattedTextField ftf = getFormattedTextField(); |
166 |
|
try |
167 |
|
{ |
168 |
|
Object newval = stringToValue(ftf.getText()); |
169 |
|
} |
170 |
|
catch (ParseException ex) |
171 |
|
{ |
172 |
|
if (!allowsInvalid) |
173 |
|
{ |
174 |
|
// roll back the input if invalid edits are not allowed |
175 |
|
try |
176 |
|
{ |
177 |
|
ftf.setText(valueToString(ftf.getValue())); |
178 |
|
} |
179 |
|
catch (ParseException pe) |
180 |
|
{ |
181 |
|
// if that happens, something serious must be wrong |
182 |
|
throw new AssertionError("values must be parseable"); |
183 |
|
} |
184 |
|
} |
185 |
|
} |
186 |
|
} |
187 |
} |
} |
188 |
|
|
189 |
/** The serialVersoinUID. */ |
/** The serialVersoinUID. */ |