Fix behaviour when typing fast.

This commit is contained in:
Gabriel Augendre 2015-06-05 15:48:10 +02:00
parent dc2d218969
commit 68d6021eb4

View file

@ -26,21 +26,9 @@ public class MainPanel {
public MainPanel() { public MainPanel() {
parse = false; parse = false;
inputField.addKeyListener(new KeyAdapter() { inputField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
parse = e.getKeyCode() == KeyEvent.VK_BACK_SPACE || inputField.getSelectedText() != null;
}
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
if (parse) {
outputField.setText(StringUtils.extractUpperCase(inputField.getText())); outputField.setText(StringUtils.extractUpperCase(inputField.getText()));
} else {
char key = e.getKeyChar();
if (Character.isUpperCase(key)) {
outputField.setText(outputField.getText() + key);
}
}
} }
}); });
copyToClipboardButton.addActionListener(e -> { copyToClipboardButton.addActionListener(e -> {