aspose file tools*
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retriving jTextfield value from an other java file