1 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {↵ | | 1 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {↵
|
2 | // remove all instances of the offending char↵ | | 2 | // remove all instances of the offending char↵
|
3 | int index = text.indexOf(c);↵ | | 3 | int index = text.indexOf(c);↵
|
|
4 | if (-1 != index)↵ | | 4 | if (↵
|
5 | {↵ | | 5 | index != -1) {↵
|
6 | if (index == text.length() - 1)↵ | | 6 | if (index == text.length() -1)↵
|
7 | {↵ | | 7 | {↵
|
8 | text = text.substring(0, text.length() - 1); // truncate string↵ | | 8 | text = text.substring(0, text.length()-1); // truncate string↵
|
9 | }↵ | | 9 | }↵
|
10 | else↵ | | 10 | else↵
|
11 | {↵ | | 11 | {↵
|
12 | text = text.substring(0, index) + text.substring(index + 1);↵ | | 12 | text = text.substring(0, index) + text.substring(index+1);↵
|
13 | }↵ | | 13 | } ↵
|
14 | ((IRestorableTextComponent) _theComponent).updateText(text);↵ | | 14 | ((IRestorableTextComponent)_theComponent).updateText( text);↵
|
15 | _beepHelper.beep(_theComponent);↵ | | 15 | _beepHelper.beep(_theComponent);↵
|
16 | ↵ | | 16 | }↵
|
17 | e.consume();↵ | | 17 | e.consume();↵
|
18 | | | 18 | }
|