aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes fieldName.setText is not setting text. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "fieldName.setText is not setting text." Watch "fieldName.setText is not setting text." New topic
Author

fieldName.setText is not setting text.

Andrew Geroge Alexander
Ranch Hand

Joined: Feb 14, 2012
Posts: 31
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....
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1088
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Andrew Geroge Alexander
Ranch Hand

Joined: Feb 14, 2012
Posts: 31
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..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18879
    
    8

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

Joined: Feb 14, 2012
Posts: 31
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..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: fieldName.setText is not setting text.