Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java Windowing Question...

Options
  • 24-02-2004 1:08pm
    #1
    Posts: 0


    Hey all,

    Just a small question about the background intricacies of Java's Swing API...

    I have a splash screen (a subclass of JWindow), which shows itself for 5 seconds and then closes (the event-handling queue closes it down, using SwingUtilities.invokeLater() ).

    Question is: When I associate this screen with the frame that calls it (associated by passing the frame to JWindow's constructor), it closes down everything, not just itself.
    The splash screen calls System.exit(0), so I guess that's the problem...however, if I just call dispose() of the JWindow subclass, will this dispose the class (freeing up resources) or will it continue to run in the background, without being shown?
    What is happening when dispose is called?

    Any clarification on this would be great, thanks for your patience.


Comments

  • Registered Users Posts: 19,396 ✭✭✭✭Karoma


    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Window.html#dispose()

    Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.


    ^
    |
    |
    java.lang.Object
      java.awt.Component
          java.awt.Container
              java.awt.Window
    
    


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    I guess JFrame.hide() might do the trick for you.

    Anytime I wrote GUI apps in any language I always wrote it as a group of existing windows, just with some hidden and some visible, i.e. all windows were packed and created when the program was started.

    Dunno if that's any help. :)


  • Posts: 0 [Deleted User]


    Yeah seamus, that sounds like a good way to do it (certainly makes it clearer to follow), although I'd have thought that would consume resources, as they're still running just hidden? That's pretty much the way mine is working now though, thanks for the link karoma, i've been reading that and i understand it a bit better now, makes sense (the java site is good alright for explanations).

    Thanks for the replies, sounds good!


  • Registered Users Posts: 6,240 ✭✭✭hussey


    How about hide it, then set it to null and let the GC take care of the memory etc?


Advertisement