This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi! Please take a look at the following code for a new user interface (that I plan to use sometime in the future). I've tied no events to any of the text fields or buttons. I'm mainly interested in your opinions in how I constructed the form itself.
I used several JPanels and 3 differnt Layout Managers to get my alignment set up. Is there a better way? Did I go over board on the Layout Managers?
This is pretty tough for someone that has only used VB to create desktop application interfaces.
Thanks for any observations you care to make.
Steve<br /> <br />No matter where you go, there you are.<br /> <br />"My evil self is at the door, and I have no power to stop it."
Unless you intend to include a "do you really want to quit" option, or similar, the window listener can be replaced by setDefaultCloseOperation(EXIT_ON_CLOSE);//in the constructor, or app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//in main()
Joined: Jul 14, 2005
Thank your for your input!
Yes that is the way I was headed.
How does this look? Action Handlers added now. Does this look like the correct way to do it?
Joined: Jun 09, 2003
Looks OK, and easy to follow.
couple of minor things
1. tfPassword.requestFocus(); from the java api docs for requestFocus(): "Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible."
2. passWord = tfPassword.getText(); from the java api docs for getText(): "For security reasons, this method is deprecated. Use the * getPassword method instead."
the return value of getPassword() is a character array, which is easily convertable to a string - one of the string constructors accepts a character array as an argument.
Joined: Jul 14, 2005
Thank you Michael! I will modify my app to include those suggestions.
My head hurts, but I think I'm starting to get the swing of things. :roll: