This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Retriving jTextfield value from an other java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Retriving jTextfield value from an other java file" Watch "Retriving jTextfield value from an other java file" New topic
Author

Retriving jTextfield value from an other java file

Tapan Prajapati
Greenhorn

Joined: Mar 05, 2010
Posts: 27
login.java

TxMgt.java


I want to retrive the value of JTextfield1 (usern) value in my second form TxMgt how can i retrive?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you change the constructor so you can pass the data when TxMgt is created
//public TxMgt() {
to

String userName
public TxMgt(String un) {
userName = un;

and in Login.java
//TxMgt tx = new TxMgt();

to
TxMgt tx = new TxMgt(jTextField1.getText());
Tapan Prajapati
Greenhorn

Joined: Mar 05, 2010
Posts: 27
Michael Dunn wrote:you change the constructor so you can pass the data when TxMgt is created
//public TxMgt() {
to

String userName
public TxMgt(String un) {
userName = un;

and in Login.java
//TxMgt tx = new TxMgt();

to
TxMgt tx = new TxMgt(jTextField1.getText());


This is for only one text field , but if in case i want to use multiple textfields of my first form into second form then? is there any other way?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
create a textfield array and pass the array
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retriving jTextfield value from an other java file