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:
@@ -143,12 +143,16 @@ public class IntField extends JTextField
|
|||||||
{
|
{
|
||||||
boolean wouldaBeenEqual = current.equals(potential);
|
boolean wouldaBeenEqual = current.equals(potential);
|
||||||
potential = transform(potential);
|
potential = transform(potential);
|
||||||
|
boolean selection = (getSelectionEnd() != getSelectionStart());
|
||||||
// we only change it if it needs changing
|
// we only change it if it needs changing
|
||||||
if (!current.equals(potential) ||
|
if (!current.equals(potential) ||
|
||||||
// or if it would have been the same pre-transforming
|
// or if it would have been the same pre-transforming
|
||||||
// and there is a selection (IE undo the selection)
|
// and there is a selection (IE undo the selection)
|
||||||
(wouldaBeenEqual &&
|
(wouldaBeenEqual && selection)) {
|
||||||
(getSelectionEnd() != getSelectionStart()))) {
|
if (selection) {
|
||||||
|
// undo the selection to not cause an exception
|
||||||
|
setCaretPosition(0);
|
||||||
|
}
|
||||||
fb.replace(0, doc.getLength(), potential, null);
|
fb.replace(0, doc.getLength(), potential, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user