• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Swing New User Interface - Opinions Please

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
reply
    Bookmark Topic Watch Topic
  • New Topic