2 Replies Latest reply: Sep 1, 2012 6:50 AM by jduprez RSS

    JDesktopPane Single JIF Open

    955780
      Hello, i wanted to ask which is the best way to keep only one InternalFrame opened on my JdesktopPane at a single time,


      My app works with a database, and i have various close-able frames that each load a different set of tables from the database. For ease of use the frames are close-able, so in the file menu i have menuitems to open each one of them, so here is where my question surges, how do i limit the user so that only one is opened at the time? should I disable the item once the frame is opened? Or how can i validate if the frame is already opened?

      every time i open a frame the information from the database will be loaded, is that correct "programming" or is there a better solution?

      Thx in advance.
        • 1. Re: JDesktopPane Single JIF Open
          Jörg
          should I disable the item once the frame is opened?
          1. I understand that you have an "Open" menu item for each frame. So if you want to have only one frame displayed at a time, you must disable all "Open" menu items.
          2. The way you describe seems to require only an open and close listener and spares a checking if any frame is already open. But the checking is not much more code. Just set and clear a flag when opening/closing a frame. It might be considered as being more user friendly, if he receives a message when trying to open a second frame. But compared to seeing disabled menus, I think this is not too big an issue.
          every time i open a frame the information from the database will be loaded, is that correct "programming"
          Only if you retrieve a huge amount of data from the db with noticeable waiting time, I would consider storing each frame's data - provided they don't change between two user requests to the same frame.
          • 2. Re: JDesktopPane Single JIF Open
            jduprez
            Aren't your single internal frames be elligible to be internal dialogs instead?
            This is described in http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html, in particular you can use the handy JOptionPane.showInternalXxxDialog(...).