This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I will post all code in a follow on. In the interest of space, I have only posted portions here. I am trying to pass values from one class if the button is pressed to another class' constructor. I am clearly not doing this correctly.
Thanks for your help.
I'll post both class files below but hopefully this text is enough to figure out what is wrong.
The method you are using to pass values to the constructor is fine.
What problems are you experiencing? Are you using the passed in values correctly? Why is your userID and password null?
Maybe you need to do: String userID = uNameString ; String password = pWordString ;
Fahd Shariff<br />"Let the code do the talking"
Joined: Apr 18, 2005
The userID and password are "null" because they are not required to log into the DB. The reason for passing the values is for use in the query "SELECT FirstName, LastName FROM CUS_USER (the table) WHERE EmailAddress = 'uNameString' (first string) AND Pasword = 'pWordString'(the second string)";
But, when I compile, I get the following error: "TestMainScreen.java:67: cannot find symbol symbol: constructor TestLogin(java.lang.String,java.lang.String) location: class TestLogin TestLogin tl = new TestLogin(uNameString, pWordString); ^ 1 error
Joined: Apr 18, 2005
The carrot in the preceding should be under new BTW.
The simple answer is: I don't know... I just kept trying things until it worked. Not very scientific to be sure.
I extended JFrame in that class only to create a new screen. I am sure that is not the right way to go about it which is why I have found this forum to be so very valuable. I have gotten more to work in the last four days due to you and Ernest's help than I have ever understood in the past. Please keep the comments coming. What I generally do is get the thing to just work. That is all I care about. After I do that, I try some other things (play with the code and see what breaks it and what makes it work with less code). For instance, I did not even try to pass these values and create a new object until I got both classes working all by themselves. Once I tried that, it broke. Then I tried a whole bunch of things until it worked again. Once you give me feedback, I make leeps and bounds. It is funny that so many of the things that I am told after I try the dumb way just seems so obvious later on. This forum has been outstanding for helping me learn.
Originally posted by Al Wells: The carrot in the preceding should be under new BTW.
That typo made my day, I'm still grinning - thanks!
If you want to preserve the formatting of your text, for example for positioning carets, you need to use code tags.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus