-
[SOLVED] Textfield
Hi, just a quick question on something that is buggin me (and i have searched google and the forums but cant find anything).
I am creating a calculator in netbeans, i have used the GUI part to create the design and i am currently writing the code for the buttons. My issue is that i cant remember nor find the code to add characters to a textfield without deleting what is already in there.
If someone can give me the code or direct me to a place where i could find it i would be most appreciative :)
Fireking
-
One way would be to get what's there now, concat the new values to it and put it back. Read the API doc for the correct methods.
-
thx after a good 10 mins that seems to work :)
Didn't know you could do that :)
the code i have for each button is as follows
Code:
private void btnOneActionPerformed(java.awt.event.ActionEvent evt) {
// if/else statement to allow me to join the numbers without adding them 'concatenate'
if (screenNo == 0)
{
txtScreen.setText("1");
screenNo = 1;
} else
concatNo = txtScreen.getText().concat("1");
screenNo = Float.parseFloat(concatNo);
txtScreen.setText(concatNo);
}