It blows up in the super.dispose() no matter where or if the removeAll
statement is used.

I have since found that it only seems to blow up if a JComboBox is the focus
when the window is closed. If I click on the exit button no problem. But if
I close by clicking the Window close box and the focus happens to be in a
JComboBox I get the error.

Also I have read the quote from the jdk doc many times and find it
misleading.  The native resources may be released but the memory of all the
components does not appear to be released unless you remove the components
from the container and you are usually successful then only if there are no
listeners or you remove the listeners (at least on 1.3.1 and prior, don't
know about 1.4). 

We have a very dynamic app in that users constantly drill down to "detail
windows" and then close windows. Disposing of the closed windows leaves lots
of garbage that is not collected. Our app never crashes with out-of-memory
error it just gets slower and slower and slower. The savy users all told us
they were exiting the app every 1-2 hours to prevent it from crawling. I
downloaded a trial version of Optimizeit and it showed lots of components
never getting garbage collected.

Several forums suggested that you need to help out by removing all
components from the container and removing all listeners from the components
that are removed. Several people suggested over-riding dispose to remove the
components and over-riding the components removeNotify method to remove the
listeners. This is where we are heading unless someone has an easier
solution.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 6:05 PM
To: JDJList
Subject: [jdjlist] Re: IllegalStateException caused by Over-riding
dispose


just a shot, I do not know what the original dispose()-method is doing...
try to use the super.dispose() call as the last statement in your method
and tell me if this changes anything, I am curious myself ;o)

perhaps the problem arises from calling "getContentPane()" after
"dispose()".
"...the resources for these Components will be destroyed..." (see below for
the full cite
of the jdk docs) might mean that there is nothing left to "get" for the
"getContentPane()" method ;o)

from the jdk docs:
---------
public void 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. 

     The Window and its subcomponents can be made displayable again by
rebuilding the native resources with a subsequent call to
     pack or show. The states of the recreated Window and its subcomponents
will be identical to the states of these objects at the
     point where the Window was disposed (not accounting for additional
modifcations between those actions). 
----------



> We were over-riding the dispose method of JFrame to try to help garbage
> collection. The method was very simple as shown below.        
> 
>       public void dispose(){
>               analyzeModel = null;
>               analyzeJTable = null;
>               super.dispose();
>               getContentPane().removeAll();
>       }
> 
> The super.dispose() call generates the following exception:
> 
> java.lang.IllegalStateException: Can't dispose InputContext while it's
> active
>       at sun.awt.im.InputContext.dispose(InputContext.java:596)
>       at java.awt.Window$1$DisposeAction.run(Window.java:539)
>       at java.awt.Window.dispose(Window.java:549)
>       at dpak.purchase.RequisitionView.dispose(RequisitionView.java:726)
>       at
> dpak.purchase.RequisitionView$7.windowClosing(RequisitionView.java:441)
>       at java.awt.Window.processWindowEvent(Window.java:1098)
>       at javax.swing.JFrame.processWindowEvent(JFrame.java:266)
>       at java.awt.Window.processEvent(Window.java:1057)
>       at java.awt.Component.dispatchEventImpl(Component.java:3526)
> 
> 
> I'm a little fuzzy about what input context it is complaining about. Any
> ideas?
> 
> 
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to