File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
 
subject: Retriving jTextfield value from an other java file
 
Similar Threads
Networked Programs that work across countries
Pressing a button to open a new window
requestfocusinwindow going to lostfocus event thrice
problem clicking jbuttons in jtable
Problem With GUI of Net Beans