• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jTextField update text?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic