|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Creating login/logout functionality with swing.Basically have a a class that implements JDialog and shows a login screen, it has a boolean value which indicates if the result was OK or not (in this case, the login was valid or the user canceled). Basically the simple functionality looks like this
[code] Login l = new Login(null, true); l.setVisible(true); if(l.getResult()) new MainForm().setVisible(true); else System.exit(0); [/code] Now this works well, if the user presses ok, the event for the button sets the result to true and the login data is valid, false if canceled. The window is shown if the result is true. The only thing is the MainForm class has a File Menu option with logout, which I intend to have the main form close and the login dialog to show up again so another use can login. I trued putting the code above in a loop with a guard that cna be changed in the main-form via a callback, but since hte main form is modeless, the login pops up right after it is shown. Also system.exit closes the entire application. Is there a way to do it the way I want? |
|
|
Re: Creating login/logout functionality with swing.Maybe it is too late for me and I am too tired to understand, but I am
not sure what exactly are you asking for. Can you provide more details about what you have already and what you want? If you don't mind, then by the way, I would like to recommend you not mixing application logic and GUI in one layer. For tiny applications it works well, but if you do build something bigger than just an example application, you will quickly become a beneficent of having your application better designed. Keep your 'bussiness logic' separated from GUI. For example: do not mix code which actually check user credentials with the code which creates and manages windows, buttons or text fields, and do not reference any GUI code from within application logic code. Witold Szczerba 2008/6/6 indigo0086 <ndig0086@...>: > > Basically have a a class that implements JDialog and shows a login screen, it > has a boolean value which indicates if the result was OK or not (in this > case, the login was valid or the user canceled). Basically the simple > functionality looks like this > > [code] > Login l = new Login(null, true); > l.setVisible(true); > > if(l.getResult()) > new MainForm().setVisible(true); > else > System.exit(0); > [/code] > > Now this works well, if the user presses ok, the event for the button sets > the result to true and the login data is valid, false if canceled. The > window is shown if the result is true. > > The only thing is the MainForm class has a File Menu option with logout, > which I intend to have the main form close and the login dialog to show up > again so another use can login. I trued putting the code above in a loop > with a guard that cna be changed in the main-form via a callback, but since > hte main form is modeless, the login pops up right after it is shown. Also > system.exit closes the entire application. Is there a way to do it the way > I want? > -- > View this message in context: http://www.nabble.com/Creating-login-logout-functionality-with-swing.-tp17693669p17693669.html > Sent from the Netbeans - UI mailing list archive at Nabble.com. > > |
| Free embeddable forum powered by Nabble | Forum Help |