• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program Flow with Classes

 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to write a program which will have a login screen, and after the login screen the main screen will be populated. Now my questions how should I organize the moving from one JFrame to another? ie
Have a login class which calls the main application class? Or the main application creates an instants of the login class. I am confused on how one should write a program with possiblity 2 or more screens, should each screen be a seperate class?
Any ideas would be great.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dean,
What I have done in the past was to create a main frame for the applet/application and it creates a modal dialog for the login window. The modal dialog is a separate class for me because I use the class in various other applets/applications (reuse!). The dialog class allows adding and removing listeners to its 2 buttons using an interface. The interface has 2 methods associated with it:
public void loginCanceled( LoginDialogEvent e );
public void loginCompleted( LoginDialogEvent e );
This way the calling program can just listen for which choice the user has selected and some information can be passed into the listening routine. For example:
public class LoginDialogEvent extends EventObject
{
private String loginName;
private String passWord;
public String getLoginName()
{
}
public String getPassWord()
{
}
}
Regards,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic