0

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.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Kuba
  • 31
  • 5
  • You need to use `JTextArea#append` or you could use something like [this](http://stackoverflow.com/questions/12945537/how-to-set-output-stream-to-textarea/12945678#12945678) which redirects the `System.out` through the `JTextArea` – MadProgrammer Feb 12 '16 at 09:24

1 Answers1

1

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");
Arun Xavier
  • 763
  • 8
  • 47
Matt
  • 1,298
  • 1
  • 12
  • 31