if() scope

if I place a constructor for a JFrame within an if statement is the memory for the JFrame released after the if statement is executed, assuming the argument is TRUE?

I need the JFrame 4 times in the method but I don't want to declare it at the beginning of the method, just in each if statement

JFrame fr =new JFrame();

[373 byte] By [larry_68a] at [2007-10-2 8:40:51]
# 1

> if I place a constructor for a JFrame within an if

> statement is the memory for the JFrame released after

> the if statement is executed, assuming the argument

> is TRUE?

>

> I need the JFrame 4 times in the method but I don't

> want to declare it at the beginning of the method,

> just in each if statement

>

> >

>JFrame fr = new JFrame();

>

A more completed code sample would have made your question less ambiguous: But I'll try to answer it as I believe you meant. Most java objects when you loose all references to them will be cleaned up by the GC the next time it runs. JFrame and other GUI objects are exceptions. After a call to setVisible(), a JFrame has an internal reference to the frame. Just loosing reference to a JFrame will not release its memory. The memory for the JFrame will not be released until it is explicitly told to do so via a close event tied to a dispose() or explicitly calling dispose().

Caffeine0001a at 2007-7-16 22:42:44 > top of Java-index,Java Essentials,New To Java...
# 2
Thank youYou answered my question so completely and wonderfully
larry_68a at 2007-7-16 22:42:44 > top of Java-index,Java Essentials,New To Java...