Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField value from one class to other class  RSS feed

 
Raghuveer Rawat
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I am new to swing programming. I am making a application in which in which in the first class I have a JTextField component called CustomerID. and in the second class I want to validate the input value of the textfield but I am unable to get the value of textfield in the second class. can any one help me?
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raghuveer,
Assuming that I understand the question correctly, the following might help:
1. If both the classes are in the same package, you could change the scope of the JTextField in the first class to package access so that it is accessible from any other class in the package.
2. Alternately, in the first class, you could have a method like

3. You could make use of an InputVerifier to validate the contents of the JTextField. You will plenty of discussions on the InputVerifier in this area.
Hope this helps,
Abhik.
[ June 24, 2003: Message edited by: Abhik Sarkar ]
 
Raghuveer Rawat
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi abhik
Thanks for your suggestion.
I think second option will solve my problem.
Thanx again
Raghuveer
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!