Hello Norm! Lightning fast!
I looked into TextField Events, but i could not find DocumentListener.
e.g. In TextFieldOne I input 20. In TextFieldTwo should not be bigger number than TextFieldOne (20), but bigger than zerro.
So if I input 100 in TextFieldTwo, the font of TextFieldTwo should turn bold and red. And if I type a letter (or two, I expressed myself wrong when I wrote 'character'), the TextField should 'clear' itself. I have came up with this code:
private void LengthTextFieldCaretUpdate(javax.swing.event.Caret Event evt) {
// TODO add your handling code here:
try {
String number = LengthTextField.getText();
Vejica.StringToDouble(number);
statusLabel.setText(String.valueOf(number));
}
catch (Exception e) {
LengthTextField.setText("");
}
}
But this does not 'clear' text in Exception on first run, but on second.
As you can see, I also use class Vejica, (decimal separator), where I change string to double:
public class Vejica {
public static double StringToDouble(String stringNum) {
String decimalCharacter = "."; //HERE I'd like to change "." for something 'Sure'
stringNum = stringNum.replace(".", decimalCharacter);
stringNum = stringNum.replace(",", decimalCharacter);
return Double.parseDouble(stringNum);
}
}
could I bother you for links
-to API doc for TextArea.
-the API doc for Double and for String
Kind regards, Grom