aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes jTextField update text? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jTextField update text?" Watch "jTextField update text?" New topic
Author

jTextField update text?

larry august
Greenhorn

Joined: Jul 19, 2006
Posts: 2
Hi ...I have a Form has fields on it and I am having issue updating the textfields.

Basically the form loads and user picks a choice from the combo box. This fires an event which connects to a database table and retrieves the first record. I can test this by doing System.print. The cosole shows me I have the correct record. I then wish to pass the value of the first record to the jTextField on the form.

When doing print test. I print the value out in the database connection class it prints correctly but if I try to print out the same value in the GUI class I get back null.

I am using setters and getters to set and retrieve the value. I assume the reason I cannot do a get on the setter is it is out of scope. So i am wondering if there is another easier way?

I thought maybe I can have the component redraw itself and pass the value to it?

Any ideas?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
often problems like your description are caused by duplicate declarations



now, any reference to tf, outside of the constructor, will generate a NPE.
if you have code similar to the above, change
JTextField tf = new JTextField(5);
to
tf = new JTextField(5);

if this is not your problem, post a sample program demonstrating the behaviour.
(hard-code values in lieu of the db stuff)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jTextField update text?
 
Similar Threads
Unit testing on multi-threads access to one database
passing references to methods
Problem in using BIRT
retreiving contents of JTextFields for logic
BIRT report parameter from Java