Fixed nonserious exception that got thrown when more than one digit was

selected and a replacement was entered.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1601 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2005-03-01 03:25:22 +00:00
parent 54010798f2
commit 439f80d23e
@@ -143,12 +143,16 @@ public class IntField extends JTextField
{
boolean wouldaBeenEqual = current.equals(potential);
potential = transform(potential);
boolean selection = (getSelectionEnd() != getSelectionStart());
// we only change it if it needs changing
if (!current.equals(potential) ||
// or if it would have been the same pre-transforming
// and there is a selection (IE undo the selection)
(wouldaBeenEqual &&
(getSelectionEnd() != getSelectionStart()))) {
(wouldaBeenEqual && selection)) {
if (selection) {
// undo the selection to not cause an exception
setCaretPosition(0);
}
fb.replace(0, doc.getLength(), potential, null);
}
}