window start up questoin

topic posted Thu, March 24, 2005 - 11:19 AM by  Terry
Share/Save/Bookmark
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
posted by:
Terry
San Diego
Advertisement
Advertisement
  • Re: window start up questoin

    Thu, March 24, 2005 - 2:58 PM
    in 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

    • _
      _
      offline 3

      Re: window start up questoin

      Thu, March 24, 2005 - 3:48 PM
      That'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.
        • B
          B
          offline 121

          Re: window start up questoin

          Fri, March 25, 2005 - 7:51 AM
          There 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 AM
            Hey 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.
            • B
              B
              offline 121

              Re: window start up questoin

              Sun, March 27, 2005 - 1:37 PM
              It 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 PM
                it'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.

Recent topics in "Java Monkeys"

Topic Author Replies Last Post
Javascripting costs Schirin 3 May 17, 2007
Design patterns and principles emblylan 6 February 14, 2007
open source hosting alternatives? Mark 2 February 3, 2007
Ruby > Java Unsubscribed 6 January 9, 2007