Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Programming backspace function in a java calculator.

807569Jul 4 2006 — edited Jul 4 2006
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2006
Added on Jul 4 2006
2 comments
571 views