2

I'am trying to send email with a 'secret key' and the user is supposed to enter the key in text field to change the password(I am making a rdbms system in java) . But I'am stuck here: Firstly I've passed a string and an integer from ForgotPassword.java to ConfirmPassword.java

     close();
     ConfirmPassword cf = new ConfirmPassword(_number,uname);
     cf.setVisible(true);

then the constructor in ConfirmPassword goes like :

public ConfirmPassword(int _number , String uname) {

    initComponents();
    this._uname=uname;
    this.number=_number;

}

but this code doesn't compile and gives me error in main 'unexpected type required: value found:class' Main:

public static void main(String args[]){
   //Some look and feel code here
   java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new ConfirmPassword(int,String).setVisible(true);
        }
    });

Basically what im trying to do is import data from Forgotpass JFrame to ConfirmPass Jframe any help is appreciated cheers! :)

Mayur Kulkarni
  • 1,306
  • 10
  • 28

1 Answers1

0

In your run method you set wrong parameters for new ConfirmPassword. You give the type to the constructor not an actual variable. You have to do it like this:

public void run() {
    int firstInt = 0;
    int firstString = "test";
    new ConfirmPassword(firstInt, firstString).setVisible(true);
}

With this code you should get rid of the exception. If you do not have the variables at the time you initialice your ConfirmPassword class you have to remove the int and String from your constructor and put it in a separate method in your ConfirmPassword class:

public void setValues(int firstInt, String firstString) {
    this.number = firstInt;
    this._uname = firstString;
}

You can call this method as soon as you set the int and String in your other class.

Deutro
  • 3,113
  • 4
  • 18
  • 26
  • but integer and the string is being inherited from another JFrame and currently their value is unknown to the current class so how can i initialise them? :( – Mayur Kulkarni Sep 18 '14 at 09:37