r3151 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor
Author: vsalaun Date: 2011-05-30 11:06:51 +0200 (Mon, 30 May 2011) New Revision: 3151 Url: http://chorem.org/repositories/revision/lima/3151 Log: prevents illegal unicode characters to show up Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-05-30 08:55:09 UTC (rev 3150) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-05-30 09:06:51 UTC (rev 3151) @@ -53,7 +53,7 @@ // the editor should return a BigDecimal public Object getCellEditorValue() { String textValue = textField.getText().trim(); - //replace all comma by fullstop + //replace all comma by full stop textValue = textValue.replaceAll(",", "."); if (textValue.equals("")) { return BigDecimal.ZERO; @@ -116,8 +116,16 @@ @Override public void keyReleased(KeyEvent e) { if (keyPressed == false) { - textField.setText(String.valueOf(e.getKeyChar())); - keyPressed = true; + if ((e.getKeyCode() >= KeyEvent.VK_0 + && e.getKeyCode() <= KeyEvent.VK_9) + || e.getKeyCode() == KeyEvent.VK_COMMA + || e.getKeyCode() == KeyEvent.VK_PERIOD) { + textField.setText(String.valueOf(e.getKeyChar())); + keyPressed = true; + } else if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE){ + textField.setText(""); + keyPressed = true; + } } }
participants (1)
-
vsalaun@users.chorem.org