I am forwarding the following message for my colleague Norm Shapiro.
Steven C. Bankes, Ph.D.
Managing Partner
Evolving Logic Associates
3542 Greenfield Ave.
Los Angeles CA 90034
310-836-0958
[EMAIL PROTECTED]
[EMAIL PROTECTED] (Nelson Minar) writes:
>I'm still getting some occasional instability when disposing of Frames
>in the Linux JDK - I get IOT trap/Abort. My application is crashing
>randomly and it's driving me nuts. Is there anything I can do to help
>find this bug (I can send complete class files and instructions that
>crash the system fairly often)? Can anyone think of a work-around?
>
>The crash happens right when I call Frame.dispose(). I'll include the
>stack frame for the running thread when the thing dies. The frame
>contains several components: a Label, a TextField, and a Button, all
>in a FlowLayout.
>
I have had similar problems with JFrame. My workaround, which has been
generally successful, was to subclass JFrame. In the subclass I override
dispose (and also setVisible()) with a method that forks off Thread with a lower
priority than the current thread. The actual disposal or setVisible(false) is
done in the forked thread.
Here is the subclass.
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class AFrame extends JFrame implements Runnable, WindowListener
{
boolean mustDispose=false;
boolean disposed=false;
boolean mustHide=false;
Window master;
AFrame(String title)
{
super(title);
}
public void dispose()
{
if(disposed)
return;
mustDispose=true;
fork();
}
protected void fork()
{
Thread thread=new Thread(this);
thread.setPriority(thread.getPriority()-1);
thread.start();
}
public synchronized void run()
{
if(mustDispose && !disposed)
{
disposed=true;
super.dispose();
}
else if(mustHide)
{
super.setVisible(false);
mustHide=false;
}
}
public void setMaster(JComponent masterArg)
{
master=(Window)masterArg.getTopLevelAncestor();
master.addWindowListener(this);
}
public void setVisible(boolean visible)
{
if(visible)
super.setVisible(visible);
else
{
mustHide=true;
fork();
}
}
public void windowClosed(WindowEvent e)
{
if(e.getWindow()==master)
dispose();
}
public void windowActivated(WindowEvent e){}
public void windowClosing(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
}
===============
Norman Shapiro
5011 Mattos Ct
Fremont CA 94536-7170
(510) 795-1800
[EMAIL PROTECTED]
------- End of Forwarded Message