java - How to call a class already implemented class in a different JFrame? -
i cant figure out how call class implemented in login.java(is jframe) in welcome.java(also jframe)
this class have called upon in login.java.
public class session { public session(string susername, string spassword, string sname, string sage, string ssex) { string username = suser; string password = spassword; string name = sname; string age = sage; string sex = ssex; } }
this login.java code implementing class.
if(rs.next()) { username=rs.getstring("usernames"); password=rs.getstring("passwords"); name=rs.getstring("names"); age=rs.getstring("ages"); sex=rs.getstring("sexes"); session s1 = new session(username, password, name, age, sex); }
in welcome.java want call upon s1 so.
s1.name
or
s1.username
if s1 session class instance private member of login (extends jframe) class, there no regular way access s1 member outside login class. need use public accessor methods (setters , getters).
if want access login's s1 object welcome class, need pass reference welcome constructor, and/or login's s1 member needs have public visibility.
welcome welcome = new welcome(login.gets1())
Comments
Post a Comment