Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Correct way to navigate from one form to another

Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I trying to develop a small swing application,
I have two frames one frame is loggin screen and the 2nd frame is a simple frame with contain a form

The login frame will have an "Ok" button and once the "Ok" button is clicked, I want my 2nd frame (which is form) to display.
I have written that piece of code, but want to make sure i do it correctly

Name of frames
1)Login Frame

This is the Action code of the Ok button present in Login Frame
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("Ok Button Pressed");
UserConnectedFrameSuccess ucf = new UserConnectedFrameSuccess();


My concerns are
1) if one user passes the login screen is it advisable to completly close it or to hide it. Here is have hidden it becoz i did not know how to close the login fram and display the other frame.

I hope i have explained it nicely. Any help would be appreciated
Posts: 69785
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably the easiest way to get rid of the login frame is to use its dispose() method.

You are declaring the next frame inside the actionPerformed method; do you really want it to be a local variable in the method?

Apart from that it looks all right to me. I am not used to this method; I usually use the ordinary addActionListener(new ActionListener() . . . form.
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if there is any delay in showing the frame (after logging in),
you may want to consider creating UserConnectedFrameSuccess() while the
login dialog is showing, then on successful login, show the frame,
and dispose the dialog
His brain is the size of a cherry pit! About the size of this ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic