Anyone out there who knows how to erase existing text with a new one. I don't think i can use something.setText("") or can I???
Basically what i did is : when a user enters 2 numbers or more the program will do the calculation and display the results. However the problem that i am facing now is when i change the numbers to a new one it will continue doing the calculation and display the results but it will add on the answer to the existing one.
I want it to erase the previous answers and display just the latest one.
I have only one button to show the answer(I tried using the ifElse statement but because there is no clear button>>its not really working as it should).
So is there any other way to automatically clear the text in the textarea(output) once the values in the textfields(input)is changed?
And is there a method to make this bold ormake anything italic without using g.setFont in graphics paint. Just curious.
Thanks in advance.
Assuming the text you want to change is in a textField you can change the text with setText(). Add a listener to the second/last text entry field and call a method that resets your textField with the new value. Should also be able to use setFont() to make it bold if that's what you want.
Yup yr correct about the setFont actually i've been using it the whole time but there was a bit of confusion there (as i was previously using textField and changed to textArea).....i am trying to get used to using textAreas..
And yes i have tried using setText as you can read in my post, however, its only displaying the last line of my answer....when i use append it tops up the new answer to the old ...and i only want the new answers.