• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

JTextField is not working for setText()

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 178
2
Netbeans IDE MySQL Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 50
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramesh

Here it is ....

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic