File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Program Flow with Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program Flow with Classes" Watch "Program Flow with Classes" New topic
Author

Program Flow with Classes

Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
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

Joined: Jan 09, 2001
Posts: 1492
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program Flow with Classes