aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Writing To A JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Writing To A JTextArea" Watch "Writing To A JTextArea" New topic
Author

Writing To A JTextArea

Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Hi Guys.

I have a java program thats works with an LDAP server. Basically, it gets some values, and outputs them to the dos console window. Problem is, I want them to go to the JTextArea on the GUI.

I have one method that creates the GUI, one that acts as actionPerformed (when I push the connect button) and then methods for getting the info I need. What I need to do is in the methods that get the info, I need to write to the text area. But because it is private I cant do it.

Anyone know how I can write to a private JTextArea from another method?

Cheers!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You could pass that text area to the method.





That is one way. There are some better ways albeit a bit more involved as it has to do with observable patterns and what not. You could also just make the text area public. Or you could have a public call back method that writes to the private text area.


GenRocket - Experts at Building Test Data
Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Thanks very much. What would the someClass bit you mentioned refer to?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Alan Jackson:
Thanks very much. What would the someClass bit you mentioned refer to?


Well, since you said that you can't access the JTextArea object because it is private, I assumed your method for accessing LDAP was in a different class than your JTextArea. someClass is that other class. If this is not the case, I'd be cuirous as to why you think you can't access a private member from the same class.
Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Got it working, thanks Gregg
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing To A JTextArea