I have created the buttons for on-screen keyboard. The only thing I don't know is how to add the corresponding letter/character via actionListener to the jTextField. I know if it was not jTextField I could use "append".

Recommended Answers

All 5 Replies

You can use getText() to get the existing text in the text field, then append your new character, then use setText() to update the field.

then append your new character,


You an use the two methods James gave you to accomplish that:

if(e.getSource() == aButton) {
    //get text already in your text field
    //add a to that
    //put text back in text field
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.