This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi Guys, this might seem easy enough, but I HAVEn't been able to get it to work.
I created a registerGUi class, where the User set his username and Id, password and other things. I then added the Listener to register button to get the username from the username field when register is clicked. Everything works fine and I can save the details to the database. However, I created another page which i called RegisterConfirmation, basically it has a text area that contains the message: Welcome "username", you have successfully registered.
to launch this Frame - RegisterConfirmation, I am creating a new object which I put in my actionlistener, but everytime I get a null value. Ofcourse coming from a Java web background, this is easy as all I have to do is put the Username in a session scope, but I am new to Swing, so it different the way I have to handle this.
I created a setter and getter for String user- which I assign the username, but it seems every time If I created a new obejct of RegisterConfirmation, and then set user to username, it runs the constructor of RegisterConfirmation before setting the value , but this time in the text area the result is null
code Register class
Registrationconfirmation class
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
if you follow the flow, it has to be null
line 10 of Register class
regconf = new RegistrationConfirmation();
which calls the constructor
and on line 20 of RegistrationConfirmation constructor
tx.setText("Congratulations " +getUser()...
where getUser() is null
user is not set (setUser) until line 11 of Register class,
i.e. after RegistrationConfirmation constructor returns
Sege Stephen
Ranch Hand
Joined: Oct 06, 2007
Posts: 51
posted
0
Michael,
That is true, but the problem I have is that I cannot call setUser() method before creating a new instance RegistrationConfirmation , because I need an instance the class to call the setUser() method. So how do I go about it?