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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java Windowing Question...

  • 24-02-2004 12: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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 6,240 ✭✭✭hussey


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


Advertisement