• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retriving jTextfield value from an other java file

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
login.java

TxMgt.java


I want to retrive the value of JTextfield1 (usern) value in my second form TxMgt how can i retrive?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
create a textfield array and pass the array
reply
    Bookmark Topic Watch Topic
  • New Topic