Advertisement
Hey Folks,
Got a problem I'm tracking down and would appreciate any thoughts or help. My applicatoin main window is a jFrame.
The first thing a user must do is log in (which gets validated against a database) and there is a menu item which displays a modal jDialog.
I thought it would be nice if the dialog was automatically displayed when the application started, so I put in a call to display it at the end of the constructor. Bad move -- the dialog comes up, but the main window hasn't been displayed yet.
I think I want to override the show method (which I'll try next)...
Terry
Got a problem I'm tracking down and would appreciate any thoughts or help. My applicatoin main window is a jFrame.
The first thing a user must do is log in (which gets validated against a database) and there is a menu item which displays a modal jDialog.
I thought it would be nice if the dialog was automatically displayed when the application started, so I put in a call to display it at the end of the constructor. Bad move -- the dialog comes up, but the main window hasn't been displayed yet.
I think I want to override the show method (which I'll try next)...
Terry
Advertisement
Advertisement
-
Re: window start up questoin
Thu, March 24, 2005 - 2:58 PMin case anyone is interested, the easiest way i found to do this is to add a windowlistener at the end of the constructor:
addWindowListener(new WindowAdapter()
{
public void windowOpened(WindowEvent event)
{
connection_manager.display_startup_dialog() ;
}
}
); // anonymous inner class
-
-
Re: window start up questoin
Thu, March 24, 2005 - 3:48 PMThat's probably a better way, but I'm curious to know if simply using EventQueue.invokeLater(new Runnable() { public void run() { /* start your dialog */ } })), would work the first way. -
-
Re: window start up questoin
Thu, March 24, 2005 - 6:31 PM
I would be worried about race conditions with that approach Aaron. The WindowOpened call is guaranteed to take place after it has been displayed.
;)
T. -
-
Re: window start up questoin
Fri, March 25, 2005 - 7:51 AMThere is an easier way.
I do dthe same thing but disable all menu items with the exception of a login option. Once login the menu items are enabled. This also allows me to time out a login for added security. -
-
Re: window start up questoin
Fri, March 25, 2005 - 10:07 AMHey Bee,
That was my old approach. But it kinda begs the question, if they've GOT to log-in, why make them do work to bring up the dialog?
Display it first, make it modal, and then they're pretty much guaranteed to be logged in -- quick & easy.
My goal is to make the interface as fool-proof as possible and as least frustrating as possible. Because, trust me, we've got a lot of frustrated fools we deal with ;)
T. -
-
Re: window start up questoin
Sun, March 27, 2005 - 1:37 PMIt actually doesn’t beg the question just put the code in a nicer place. You can always bring up a popup first to force a login. I also do this for some apps. However for real security I also allow timeouts of the login so that someone stepping away from their desk can’t have their app used. It also allows for a logout without having to kill the app. In these cases disabling everything but the login is what I do. SO you can have all options at once and you eliminate any race conditions. -
-
Re: window start up questoin
Thu, April 7, 2005 - 9:53 PMit's been ages since i had to come up with a rich client. but i seem to recall that as a habit, i did not make the jFrame my executable.
i tended to have a plain old object. it in turn would start the jframe at a suitable point, i.e. after a user has been authenticated.
good practice? bad practice? i dunno. but it worked.
-
-
-
-
Re: window start up questoin
Fri, March 25, 2005 - 4:29 PMRight, the window event listener is better, I was just curious if the other way would work.
-
-
-