Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issues with modal dialogs



> I am new to the group . We are having certain issues with java on mac.
The
> modal dialogs seem to create a phantom image even after they have been
> disposed. There happens to be no other solution to disposing them other
than
> shutting down the jvm. Please let me know of any possible solutions to
this.

Hi Barry,

I asked about this same problem a couple months ago and someone else posted
sample code to reproduces the problem.

This is definately a 1.4.1 problem (it does not happen on 1.3.1). And I
don't know if it was submitted to Apple as a bug or not.

The post with the sample code follows:

Thanks,

Stephen Legge
email@hidden


>>>
Hi.

I just noticed this problem yesterday, and have been working through
it, with no luck.

It appears that if you bring up a modal JDialog, and it brings up a
modal JDialog (or JOptionPane), then they don't dispose properly.
You're left with a "ghost" modal dialog that cannot be dismissed, but
the application won't quit (doesn't respond to quit messages, and the
"close" option on the application menu is disabled) because it's
convinced there's still a modal dialog floating around out there.

I've included at the bottom of this message a complete shortie program
that illustrates the problem. Try it with the calls to JOptionPane and
the creation of TestDialog2 in TestDialog commented out. It works fine,
as near as I can tell. However, if you uncomment either the
JOptionPane call or the invocation of TestDialog2, then you (often, but
not always) get the problem that Stephen pointed out... a ghost dialog
that won't die.

I'll submit a bug report on this one. This is a major problem... Users
tend to get upset when they can't exit an application (duh...). And
having a dialog bring up a popup informative box isn't such an uncommon
thing to want to do.

Here's the code. Sorry about the style; it's something I hucked
together to demonstrate the problem.

If anyone has a solution, please post it to the list.. I'd be grateful.

Cheers,

Mike Harm
email@hidden

///////////////////////////
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class DialogFun extends JFrame
{
public DialogFun()
{
super("Dialog Test");
JButton b = new JButton("Create Dialog");
b.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent ae)
{
TestDialog dlg = new TestDialog();
}
});
getContentPane().add(b);
pack();
setVisible(true);
}

class TestDialog extends JDialog
{
public TestDialog()
{
super((Frame)null,"a test dialog",true);
JButton okButton = new JButton("OK");
okButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent ae)
{
//JOptionPane.showMessageDialog(null,"about to go
away","bye",JOptionPane.ERROR_MESSAGE);
TestDialog2 dlg = new TestDialog2();
setVisible(false);
dispose();
}
});
getContentPane().add(okButton);
pack();
setVisible(true);
}
}

class TestDialog2 extends JDialog
{
public TestDialog2()
{
super((Frame)null,"another test dialog",true);
JButton okButton = new JButton("OK");
okButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent ae)
{
setVisible(false);
dispose();
}
});
getContentPane().add(okButton);
pack();
setVisible(true);
}
}

public static void main(String args[])
{
DialogFun dlg = new DialogFun();
}
}
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Issues with modal dialogs (From: "Barry" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.