• 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

fieldName.setText is not setting text.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Background of problem : I have created a Form that has several Text field, trying to link to the backend DB to display data on the from.

Problem : I have used the fieldName.setText property to set the value that I am getting from the Query, for some reason it is not setting the value..

As you can see, the System.out.print does print the values right.. But I cannot see it on my Form view.. Why would that be?

Does it make a difference if they are on different panels? I have one jFrame and three jPanels.. All the text fields are scattered among these panels like Title maybe in Panel1 and F_Name in Panel2 etc....
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mention that you added the field to 'Form'. What is Form? is it your own class? does it extend JPanel?

First of all, does your screen display properly i.e is the text field visible? I would suggest you to write a small program without the DB part and try the call to setText directly.
 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Form is just the way I call it.. It is just a Panel with all the TextFields on it..

The text fields are all visible.. However I tried adding something like

Even which did not seem to appear..
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, clearly you've done something wrong then. But from the code you've posted, it's impossible to tell what that is. In fact we can't even tell what kind of component txt_TITLE is.

So you're going to have to post your code. But we don't want to see 900 lines of code, if that's what you have. What we need to see is a small example which demonstrates the problem. Read the page here: SSCCE which explains that in more detail.
 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.. Sorry it was something I did.. I called a non static function by creating an object, before the default constructor was called.. thus making the previous object void/overridden by the normal constructor.. So i deleted the default coding and it works..
 
reply
    Bookmark Topic Watch Topic
  • New Topic