Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jTextField update text?

 
larry august
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic