This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes The textarea is not getting value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "The textarea is not getting value" Watch "The textarea is not getting value" New topic
Author

The textarea is not getting value

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103


My problem is that the textarea in the local inner class is not getting the value that i type when i run the code and click the get from the menu . It is supposed to take the value from the textarea and then print it on command line .
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

1. Always, always, to get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem. That means eliminating all unrelated stuff such as setting fonts and borders, and removing unnecessary vertical white space. Remember, the shorter it is, the more members will read it.

2. Learn to use layouts correctly. That means no calls to setBounds(...). I'm sure you've been told this before.

3. Use meaningful variable names. Names like jta1, jep1, jfc1 aren't.

4. I don't see anywhere in the posted code that jta1 is added to the visible component hierarchy, so why does it surprise you that its text remains empty?


luck, db
There are no new questions, but there may be new answers.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Here is the bare minimum (doesn't work, but allows to see the problem) :


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

And the problem is that once again, the JTextArea jta1 isn't added to a visible component hierarchy. Isn't that obvious to you?
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
@ Darryl Don't you think that i added the textarea through a JScrollPane ?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

1. In the first code posted, that JScrollPane isn't added to any container.

2. In the second code posted, there's no JScrollPane.
 
Don't get me started about those stupid light bulbs.
 
subject: The textarea is not getting value