Kuba
Kuba

Reputation: 31

Console out.print in JTextArea

I have some silly problem. I need to "out.print" the results to a JTextArea just as it does with a console:

for (int m=0;  m<mieszkanie.length;  m++) {
    boolean test = false;
    String test1 = mieszkanie[m];
    for (int n=0;n<mieszkanieID.length;n++) {
        String test2 = mieszkanieID[n];
        if (test1.equals(test2)){
            test = true;
            break;
        }
    }
    if (test==false) {
        System.out.println(test1);
        //JTextArea = "poleStatusu"
    }
}

With System.out.println() it of course prints every single "false", but when I use poleStatusu.setText(test1) it just prints the last "false".

What I need is just something to print every "false" in the poleStatusu text area - it doesn't matter if it's going to connect the Strings or to make JTextArea as a console. I know these methods exist, but I'm not sure how to implement them correctly.

Upvotes: 0

Views: 161

Answers (1)

Matt
Matt

Reputation: 1308

First of all you must create an object of JTextArea. Then you can set the text by append method. Like this:

JTextArea jText = new JTextArea(10, 30);
jText.append("some text");

Upvotes: 1

Related Questions