473,466 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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(true). 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
rm******@shaw.ca

Jul 17 '05 #1
1 4875
Richard Morris wrote:
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(true). 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.


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
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DJkapi | last post by:
How to close JInternalFrame? I dont want to hide it. I want to close it as normal Frame. Regards DJKapi
15
by: Chris Capel | last post by:
I've heard a lot of talk on the forum about memory managment in .NET and disposing things, finalizing them, garbage collection, etc. My question is which managed types need to be disposed after...
10
by: Patrick De Ridder | last post by:
I have been looking at an example, and there is something I don't inderstand. Given: form1 calls form2 --------- Question: What is the use of having these lines in form2 --------------...
4
by: Dakkar | last post by:
I have a program with windows forms and after execution of my program im making it invisible for working background progress and i have a dispose function like this protected override void...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
5
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? ...
0
by: thesti | last post by:
Hi, i wonder how to let a JinternalFrame get the focus immediately aftes it's poped up. so that it can respond to the KeyEvent. because in my app, the user has to click(activate) the frame in...
4
by: Peter Webb | last post by:
I am supposed to manually dispose of some instances, such as Brushes, right? I have a couple of questions: 1. I have the following code, and it works just fine: ...
29
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
3
by: medicinesoup | last post by:
I am using Visual Basic .Net 2005 professional. From what I understand, I should be disposing of any object that is an unmanaged resource. I understand the best way to tell if a resource is...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.