1 Attachment(s)
using objects from one jFrame on a different jFrame
hi
I have to forms, A login form and a main form. The login form has a username, password and a combo box and a combo box that allows you to choose the type of user (cashier, supervisor and administrator). My login form works, but i want to know how i can use the selected item from the combo box in the main form. can anyone explain to me how to do this? i just started learning java this year and am struggling with this question. Below i attached a picture of the login form: Please help me
Attachment 746
Re: using objects from one jFrame on a different jFrame
You have to pass the values as parameters into setter functions in your "main form" class, or you have to return them in getter functions in your "login form" class. This will require you to have access to one class from the other.
Or you could use a dialog.
Re: using objects from one jFrame on a different jFrame
i created a constructor in the login form to determine what kind of user was selected, but it is only returning 0. The constructor is like this:
public class loggedInAs {
int logo;
loggedInAs (){
logo = cmbLogin.getSelectedIndex();
}
int whousing (){
return logo;
}
}
and i am calling it in the main frame like this:
loggedInAs user = new loggedInAs();
personloggedon = user.whousing();
why is the index of the selected item not changing?
Re: using objects from one jFrame on a different jFrame
If you want help, you'll have to provide an SSCCE (the smaller, the better) that demonstrates the problem.
I also strongly suggest you follow the standard naming conventions- classes start with a capital letter, variables and methods with a lowercase letter.