JInternalFrame not disposing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Morris

    JInternalFrame not disposing

    Hi,

    I was wondering if someone might be able to shed some light on a problem
    that I have. This application that I am writing has several JInternalFrames
    but some of them can only have one instance open at any time. So in my
    application I have references to these specific internal frames.

    Right now I have it set up so that when the user clicks on the menu item to
    open the internal frame, if the reference is null then the internal frame is
    created otherwise is does a selectFrame(tru e). When the internal frame is
    closed I hide it and then call dispose(). However, after the dispose() is
    called the reference isn't turning into a null so when the user clicks on
    the menu item a second time the internal frame doesn't show up.

    I have read a couple of messages on the newsgroups which seem to indicate
    that if the reference isn't becoming null it is probably because there are
    some event handlers that aren't giving up their references. I also have
    done a toString() while the internal frame is active and after it has had
    its dispose() called. The toString() text looks almost identical except for
    the fact that in the disposed toString() there is an "invalid" text
    presumable to indicate that the internal frame is invalid.

    I guess my question is three parts:

    1) Is there a way to find out what references to the internal frame still
    exist at the time you wish to close the internal frame? I am assuming that
    this could be one of the reasons that my reference to the internal frame
    isn't becoming null after I call dispose();

    2) Is there a way to find out if the internal frame is "invalid" after I
    call the dispose(). In this case I could simply assign null to my reference
    of the internal frame and then go about creating a new instance of it.

    3) May be someone could suggest a better way to control how many instances
    of a specific internal frame are created at any given time. Like I said
    before, I only want one instance of this internal frame displayed at any
    given time.

    Any light that someone could suggest would be of great help to me. Thank
    you.

    --

    Richard Morris
    rmmorris@shaw.c a



  • Christophe Vanfleteren

    #2
    Re: JInternalFrame not disposing

    Richard Morris wrote:
    [color=blue]
    > Hi,
    >
    > I was wondering if someone might be able to shed some light on a problem
    > that I have. This application that I am writing has several
    > JInternalFrames
    > but some of them can only have one instance open at any time. So in my
    > application I have references to these specific internal frames.
    >
    > Right now I have it set up so that when the user clicks on the menu item
    > to open the internal frame, if the reference is null then the internal
    > frame is
    > created otherwise is does a selectFrame(tru e). When the internal frame is
    > closed I hide it and then call dispose(). However, after the dispose() is
    > called the reference isn't turning into a null so when the user clicks on
    > the menu item a second time the internal frame doesn't show up.
    >
    > I have read a couple of messages on the newsgroups which seem to indicate
    > that if the reference isn't becoming null it is probably because there are
    > some event handlers that aren't giving up their references. I also have
    > done a toString() while the internal frame is active and after it has had
    > its dispose() called. The toString() text looks almost identical except
    > for the fact that in the disposed toString() there is an "invalid" text
    > presumable to indicate that the internal frame is invalid.
    >
    > I guess my question is three parts:
    >
    > 1) Is there a way to find out what references to the internal frame still
    > exist at the time you wish to close the internal frame? I am assuming
    > that this could be one of the reasons that my reference to the internal
    > frame isn't becoming null after I call dispose();
    >
    > 2) Is there a way to find out if the internal frame is "invalid" after I
    > call the dispose(). In this case I could simply assign null to my
    > reference of the internal frame and then go about creating a new instance
    > of it.
    >
    > 3) May be someone could suggest a better way to control how many instances
    > of a specific internal frame are created at any given time. Like I said
    > before, I only want one instance of this internal frame displayed at any
    > given time.
    >
    > Any light that someone could suggest would be of great help to me. Thank
    > you.
    >[/color]

    If you only want just one instance of a specific class, you should check out
    the singleton pattern. Google around and you will find plenty of references
    for it.

    --
    mvg,
    Christophe Vanfleteren

    Comment

    Working...