6 Replies - 844 Views - Last Post: 08 August 2012 - 06:46 AM Rate Topic: -----

#1 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Pass Variables from form to form

Posted 07 August 2012 - 10:31 PM

I have created an application with 3 frames
I want to get the username in frame1 to the frame3 while I want to get useraddress in the frame2 to frame 3.

I did it by making a constructor in frame3 to get above values,
But the question is that it doesn't allow me to create 2 constructors with String type parameters.

Can anyone help me in this case?
I just want to know how two string variables in two forms can be brought to another form,
Please help me...

Is This A Good Question/Topic? 0
  • +

Replies To: Pass Variables from form to form

#2 Benzoate  Icon User is offline

  • D.I.C Head


Reputation: 51
  • View blog
  • Posts: 223
  • Joined: 29-February 12

Re: Pass Variables from form to form

Posted 07 August 2012 - 10:33 PM

The code is always very useful when helping problems like this :)
Was This Post Helpful? 0
  • +
  • -

#3 CasiOo  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 991
  • Posts: 2,200
  • Joined: 05-April 11

Re: Pass Variables from form to form

Posted 07 August 2012 - 10:39 PM

If it is because a constructor with two string parameters already exist, then you could either make a constructor with 4 parameters or make an init method which you will call with your arguments
Was This Post Helpful? 0
  • +
  • -

#4 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Re: Pass Variables from form to form

Posted 07 August 2012 - 10:59 PM

Thanks Casio...

Benzoate...It is with long code here is what I want to do...
.....
    Logon(String text) {
        getUser=text; //getuser is already defined
        initComponents();
        
Logon(String text1){
         getUserAddress=text1;//getUserAddress is already defined
         initComponents();
}
    }



I cannot add the second one. It is obvious for me why it can't be added. But I am asking you is a remedy.
Was This Post Helpful? 0
  • +
  • -

#5 smohd  Icon User is offline

  • Critical Section
  • member icon



Reputation: 1745
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Pass Variables from form to form

Posted 08 August 2012 - 01:41 AM

You cant have two constructors (methods) with the same definition and parameters list. If you want to pass two parameters then just one constructor that passes two parameter will do the work. So something like:
Logon(String text, String text1){
   getUser=text;
   getUserAddress=text1;


Hope that will help
Was This Post Helpful? 1
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8016
  • View blog
  • Posts: 31,118
  • Joined: 06-March 08

Re: Pass Variables from form to form

Posted 08 August 2012 - 03:28 AM

or
.....
    Logon(String text) {
        getUser=text; //getuser is already defined
        initComponents();
        
    Logon(String text1, int dummyParamNotUsed){
         getUserAddress=text1;//getUserAddress is already defined
         initComponents();
}
 


Was This Post Helpful? 1
  • +
  • -

#7 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Re: Pass Variables from form to form

Posted 08 August 2012 - 06:46 AM

Thanks pbl and smohd...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1