• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField is not working for setText()  RSS feed

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers

I am trying to send a value from one class to another class in Java Swing.

I wanted to display a string value in the JTextField and unfortunately I am failing to do that. But the getText() is displaying the answer well.

Below is the code and kindly help me understand where the problem is.



The function test() is the one giving the problem.

public void test(String ctryName)
{ System.out.println("I have reached here" + ctryName);
System.out.println("Before Updating: "+ countryName.getText());
String abc = ctryName;
countryName.setText(abc);
jTextField3.setText(abc);
System.out.println("Text is: "+ countryName.getText());
}


Awaiting your usual prompt support.
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the problem you get when trying this..? From where you call test method..?
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramesh

I am calling this function from another class.

When i run this, i can see the values are actually passing in System.out.println.

But the actual JTextField (countryName) is not displaying any field.

Regards / Aravind
 
Daniel Hirning
Ranch Hand
Posts: 50
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aravind,

This is a lot to go through, and as you know uncompilable for us to test.

Just a few things I noted that may help you.

1, You could have saved your self a lot of typing by importing javax.swing.*
2, AFAIK in this case, you don't need to call super yourself.
3, The strings that you want to get/set, maybe you could give an example of the output after each line in your Test method.
(This may help the staff figure out what is going wrong).

regards,
Daniel
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you put the code, how you show the JInternalFrame and how you call the test() method.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramesh

Here it is ....

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramesh

Sorry I found my mistake.

I initialized the object lList and recreate another object iList .

I have rectified it and thankyou very much for your time.

Regards / Aravind
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!