aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Swing New User Interface - Opinions Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing New User Interface - Opinions Please" Watch "Swing New User Interface - Opinions Please" New topic
Author

Swing New User Interface - Opinions Please

Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
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


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."
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Looks fine.

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()
Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
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?

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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.
Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing New User Interface - Opinions Please
 
Similar Threads
How can I get the GridLayout to work in this program
basic concept for swing
Enter # in JTextField, draw = # ovals, use JBottons to color ovals???
I enter a password into a JPasswordField, but nothing happens??
double to text