Article View: borland.public.jbuilder.java.swing
Article #12675Re: JInternalFrame : finalize method - PLEASE HELP !!!!
From: Nadia Akrour
Date: Fri, 20 Nov 1998 00:00
Date: Fri, 20 Nov 1998 00:00
67 lines
3248 bytes
3248 bytes
Thanks for your help !!
But I have some other problem now with the finalize() method.
First, I have a JDialog with a JPanel with a JComboBox in it. The combo is
initiated with some items and a listener, something like this :
public class MyDialog extend JDialog {
....
.....
JComboBox m_choiceLangue = new JComboBox(new String("french","english"));
m_choiceLangue.setSelectedItem("french");
m_choiceLangue.setPreferredSize(new Dimension(100, 20));
m_choiceLangue.setLightWeightPopupEnabled(false);
m_choiceLangue.setFont(m_font);
ItemListener m_choiceListener = new java.awt.event.ItemListener() {
public void itemStateChanged(ItemEvent e) { onLangChanged(e);} };
m_choiceLangue.addItemListener(m_choiceListener);
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout(FlowLayout.LEFT,30,2));
panel3.add(m_textControlLangue);
panel3.add(m_choiceLangue);
Now if I had the JCombo to panel3 the dialog don't get finalized . When I
comment the last line the dialog get finalized. Is there something that I'm
missing...
Is it a JComboBox bug ?
In the JDialog dispose() and finalize() methods I set the reference objects
to null.
I have a similar strange problem with a JTree. The creation is OK. But when I
add it to the JPanel in the dialog , the dialog is not freed.
Any help would be greatly appreciated.
Nadia.
dwyatt@innocent.com wrote:
> On Thu, 19 Nov 1998 19:09:38 +0100, Nadia Akrour <akrour@spring.fr>
> wrote:
>
> >Hi,
> >I have a JInternalFrame and I have implemented the finalize() method.The
> >problem is that the method seems not to be called. Have anyone some
> >experience of this ???
> >The JInternalFrame has just a JPanel in it. Is there something else to
> >do to free a JInternalFrame.
> >Any help would be very appreciated !!
> >Thanks in advance.
> >Nadia.
> >
>
> The finalize() method is not normally guarranteed to be called. There
> is a class method provided (under the System(?) class) called
> runFinalizersOnExit() that will make sure all finalizers are called.
>
> However, this method has been deprecated ( or was as of 1.2beta4 ).
>
> My suggestion is to provide a close() method of some type in your
> subclass of JInternalFrame & call that. I would also use the
> finalize() method to make sure that the close() method had been
> called, and signal an error if it has not been. This will have the
> effect of having the finalize() method do a check on the use of the
> object; which can effectively tell you if resources are getting closed
> even if it's not always invoked.
>
> --Doug
Technical Details
Message-ID:
<3655A84A.CA74516B@spring.fr>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36545EE1.8257D5FF@spring.fr> <36549fec.10243010@forums.inprise.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,94fd7b1bf8ac8733 X-Google-Attributes: gid111d45,public From: Nadia Akrour <akrour@spring.fr> Subject: Re: JInternalFrame : finalize method - PLEASE HELP !!!! Date: 1998/11/20 Message-ID: <3655A84A.CA74516B@spring.fr> X-Deja-AN: 413933679 Content-Transfer-Encoding: 7bit References: <36545EE1.8257D5FF@spring.fr> <36549fec.10243010@forums.inprise.com> X-Accept-Language: fr-FR,en Content-Type: text/plain; charset=us-ascii Organization: SPRING TECHNOLOGIES Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing