Programming backspace function in a java calculator.
807569Jul 4 2006 — edited Jul 4 2006I am doing a java calculator.
I want to program the backspace function, here is the code I have:
private void jbbackspaceMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
caja=Float.valueOf(jtfpantalla.getText()).floatValue();
if(caja==0){
jtfpantalla.setText("0");
}
else{
char caja2;
caja2=Float.toString(caja);
caja2.getChars(0,24,caja2,0);
}
jtfpantalla.setText(String.valueOf(caja));
}
Netbeans sends me 2 errors. I don't know how to use caja, as string or as an array. I want to convert it ,to print the characters of the array except the last character when the backspace button will be pressed.
I want to count the decimal point as another character, and print the characters except the last two when the decimal point is the penultime in the array.