If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Accessing JTextArea from another class

Hi, I've been programming for quite a long time in PHP and other web programming languages but I'm really new to Java. And as I've been using a procedural approach when programming in PHP I'm quite new to OOP as well. Now I'm following a very basic Java tutorial.

Don't. Keep them separate, one to present the output, and one to process the data.
There are several routes you can go with though. You can take a Document type, or a StringBuilder and append to that for example, or you can simply return a string. I'd do neither and opt for using single property accessor's instead, but if I were to group them I'd return a string:

Unfortunately I don't believe there is a really generic interface to work with when it comes to the swing JTextArea. Document I think is the lowest you can really go, and its still a javax.swing.text type. There's some patterned approaches you can follow as well, but those are more advanced and require a good understanding of OOP to implement.