Java Appending a character to a textarea

Posted by adam08 on Stack Overflow See other posts from Stack Overflow or by adam08
Published on 2010-05-02T21:54:25Z Indexed on 2010/05/02 21:58 UTC
Read the original article Hit count: 248

Filed under:
|
|
|

I'm looking to appends a character to a textarea in. I have a simple GUI designed to look like like a mobile phone and I want to be able to click on one of the buttons and update the textarea with that character. If I click another button, I want to be able to append that character to the first. How do I do this? Obviously right now it is just setting the character for that button in the textarea and will be replaced when another button is clicked.

public void actionPerformed(ActionEvent e) {
    String source = e.getActionCommand();
    if (source.equals("1")) {
        TextArea.setText("1");
    } else if (source.equals("2abc")) {
        TextArea.setText("a");
    } else if (source.equals("3def")) {
        TextArea.setText("e");
    } else if (source.equals("4ghi")) {
        TextArea.setText("i");
    } else if (source.equals("5jkl")) {
        TextArea.setText("k");
    } else if (source.equals("6mno")) {
        TextArea.setText("o");
    } else if (source.equals("7pqrs")) {
        TextArea.setText("s");
    } else if (source.equals("8tuv")) {
        TextArea.setText("t");
    } else if (source.equals("9wxyz")) {
        TextArea.setText("x");
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about gui