Results 1 to 4 of 4
Thread: public jTextField ?
- 06-06-2011, 07:11 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
public jTextField ?
Ok simple question! I have a swing jFrame in a netbeans java application project and a jTextField inside of it. Is there any possible way of retrieving the text from the textField using another class? Obviously i cannot do that because the textField is declared private in swing awt but i was wondering if there is any way around it.
Thanks in advance!
- 06-06-2011, 08:23 PM #2
Add a public getter method that can get the contents and return it.
Are these Java SE classes you are talking about? The lowercase j makes me wonder.
- 06-07-2011, 08:35 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
@Norms - maybe its the component name like jTextField1, jTextField2 and so on.
It is the name being assign by netbeans at design time but it can be change.
@OP - you also have to create instance of that class then call the getter method
Java Code:public class ClassA { ... public String getTextFieldText() { jTextField1.getText(); } } public class ClassB { ... ClassA aClassA = new ClassA(); private void textFromOtherClass() { aClassA.getTextFieldText(); } }Last edited by mine0926; 06-07-2011 at 08:37 AM.
- 06-07-2011, 10:56 AM #4
Similar Threads
-
public @interface ??
By alexoffspring in forum New To JavaReplies: 4Last Post: 02-15-2011, 10:13 AM -
public variables?
By dyelax in forum New To JavaReplies: 9Last Post: 12-27-2010, 11:17 PM -
What is the difference between Public Static Void and Public Void?
By whateverme in forum New To JavaReplies: 1Last Post: 12-04-2010, 05:41 PM -
Err:java.io.IOException: public key ring doesn't start with public key tag
By Deepa in forum New To JavaReplies: 5Last Post: 06-26-2009, 03:03 AM -
how to access jTextField of one JFrame1 from JFrame2 & Modify JTextField contents
By sumit1mca in forum AWT / SwingReplies: 1Last Post: 01-30-2009, 06:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks