This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes text area question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "text area question " Watch "text area question " New topic
Author

text area question

Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
How do I make an error message like this, generated by a member of a package



show up in a text area of a different member of the same package?

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

What part of that are you having a problem with? Catching the exception? Turning it into text? Writing it to a text area?

And by the way I don't understand what these "packages" are which you mention.
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
There are 2 members of the same package --



One member -- Scheduler.java -- generates the error message. The problem is that I want to write the text of that message into a text area called statusTextArea that is located in a second member of the combocontrol package called ComboControlView.java. If I just write it this way within Scheduler.java



I get the expected error message "cannot find symbol: variable statusTextArea". How do I amend the statement to show the text area's proper location in ComboControlView.java?
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
Or maybe someone could tell me what topic I'm looking for and I could google it. I've been looking but I don't think I'm describing it correctly in search terms.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Okay. Your question appears to be the very common one "How do I allow one class to access members of another class?"

That's asked quite regularly around here. I have tried to answer it in the past but my answer always seems to turn into a long spiel about object-oriented design; unfortunately the question is usually asked by somebody who doesn't have a really strong grasp of what an object is and why you might want to design one, so it's wasted time all around.

So I'm giving up on that strategy. Sorry for the non-answer. Perhaps somebody else would like to give it a try.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Access instance variable of class A from B. Hmmm.

One way of doing it. Refer code comments



Another way of doing it. Notice the getInstance() method in ComboControlView. This way you dont need to pass and store the references via the constructor. More loosely coupled than the code above


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
This is a great answer. It's very clear. Thank you so much.
 
jQuery in Action, 2nd edition
 
subject: text area question
 
Similar Threads
GUI: Cut/Copy/Paste/Etc.
getResource() properties file in package How to put contents in text area?
problem adding JScrollPane to JTextArea
I have a doubt
confusion regarding protected keyword