Rachel
Rachel

Reputation: 23

How to display text onscreen when multiple buttons are pressed

I have created an onsceen keyboard using JButtons. I was wondering if there is a way that I could display the text every time a button is pressed. I dont want the text overwritten when a different button is pressed. for example three buttons: 'A' 'B' 'C' when all buttons are pressed "ABC" is displayed in the textbox. i will then use the text in the text box and check to see if it matches a certain string. I have considered using setText(); but this would overwrite the text in the textbox when a new button is pressed. Thanks

Upvotes: 0

Views: 128

Answers (1)

JB Nizet
JB Nizet

Reputation: 691845

field.setText(field.getText() + newText);

Upvotes: 1

Related Questions