-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0, 7u2
-
beta
-
x86
-
windows_nt
Name: ks88420 Date: 08/31/2000
java version "1.3.0rc3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc3-Z)
Java HotSpot(TM) Client VM (build 1.3.0rc3-Z, mixed mode)
Any modal dialog can apear many times on the screen when the are instantiated
from an button ActionListener and the buttton was quickly clicked many times.
please find a source example here where you can yourself quickly click on
the 'Show it' buttton manually, or use the simulation button (robot
implementation) to simulate a fast double click and see the File chooser appear
twice, one on top of the other.
It seems that this bug has already been reported (Bug ID: 4195148 Hitting Enter
Twice Quickly Brings Up Two Modal Dialogs, Bug ID: 4031353 two bugs: disabled
button handles events creating modal dialogs, resized ...)but was always closed
because non reproducible, I hope the example will show it to you.
Find below the source the stack trace displayed in the actionPerfom of 'Show
it' button :
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
//import studioplus.publictools.misc.*;
/**
* This class purpose is to demonstrate the bug of showing more than 1 modal
dialog
* instantiated in a button actionPerform when button clicked more than once
quicky.
* This bug can be seen in the Swingset2 demo in the color chooser demo by
double clicking
* quickly on the background button for instance, this will show up 2 color
chooser modal
* dialog boxes
* click on the simulation button, it may not work all the time but try again
and it will work.
* using jdk 1.3
* using windows JDK on NT 4 sp5
* @author Sebastien Gandon
*/
public class DemoManyModalDialog
{
/**
* Unitary test / Main entry point
*/
public static void main(String[] args)
{
final JFrame mainFrame = new JFrame();
final JButton showButton = new JButton("show it");
mainFrame.getContentPane().add(showButton, BorderLayout.NORTH);
//add a listener to the show button to show a modal dialog box
//in this case the file chooser, it does the same for any modal
dialog
//can be test by double clicking on the button directly
showButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//Env.trace("actionPerformed" + "\n" + Env.getStack());
JFileChooser jfc = new JFileChooser();
jfc.showOpenDialog(mainFrame);
}
});
//use of a robot to simulate a fast double click
final Robot robot;
// check whether the OS accepts robots.
try {
robot = new Robot();
} catch (Exception e) {
System.err.println("Your system does not allow
robots.");
return;
}
//build the simulation button to reproduce programaticaly the
problem
final JButton simulationButton = new JButton("Click here to
simulate 2 clicks on the 'Show it' button");
mainFrame.getContentPane().add(simulationButton);
simulationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread robotThread = new Thread() {
public void run() {
//click twice on the
showButton
Point point = new Point
(5,5);
SwingUtilities.convertPointToScreen(point, showButton);
robot.mouseMove
(point.x,point.y);
robot.mousePress
(InputEvent.BUTTON1_MASK);
robot.mouseRelease
(InputEvent.BUTTON1_MASK);
robot.mousePress
(InputEvent.BUTTON1_MASK);
robot.mouseRelease
(InputEvent.BUTTON1_MASK);
}
};
robotThread.start();
}
});
mainFrame.setTitle("bug demo for many modal coming up");
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
}
Here is the stack trace :
you will note that the second call to actionPerform is done from the event
queue newly created in the java.awt.Dialog.show(Dialog.java:370).
- studioplus.publictools.misc.Env.getStack(Env.java:103)
- DemoManyModalDialog$1.actionPerformed(DemoManyModalDialog.java)
- javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
- javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
(AbstractButton.java:1504)
- javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel.java:378)
- javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
- javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonListener.java:216)
- java.awt.Component.processMouseEvent(Component.java:3717)
- java.awt.Component.processEvent(Component.java:3546)
- java.awt.Container.processEvent(Container.java:1164)
- java.awt.Component.dispatchEventImpl(Component.java:2595)
- java.awt.Container.dispatchEventImpl(Container.java:1213)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
- java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
- java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
- java.awt.Container.dispatchEventImpl(Container.java:1200)
- java.awt.Window.dispatchEventImpl(Window.java:912)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
- java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
- java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
- java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
- DemoManyModalDialog$1.actionPerformed(DemoManyModalDialog.java)
- javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
- javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
(AbstractButton.java:1504)
- javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel.java:378)
- javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
- javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonListener.java:216)
- java.awt.Component.processMouseEvent(Component.java:3717)
- java.awt.Component.processEvent(Component.java:3546)
- java.awt.Container.processEvent(Container.java:1164)
- java.awt.Component.dispatchEventImpl(Component.java:2595)
- java.awt.Container.dispatchEventImpl(Container.java:1213)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
- java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
- java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
- java.awt.Container.dispatchEventImpl(Container.java:1200)
- java.awt.Window.dispatchEventImpl(Window.java:912)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
- java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
- java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
- java.awt.Dialog.show(Dialog.java:370)
- javax.swing.JFileChooser.showDialog(JFileChooser.java:620)
- javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:517)
- DemoManyModalDialog$1.actionPerformed(DemoManyModalDialog.java)
- javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
- javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
(AbstractButton.java:1504)
- javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel.java:378)
- javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
- javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonListener.java:216)
- java.awt.Component.processMouseEvent(Component.java:3717)
- java.awt.Component.processEvent(Component.java:3546)
- java.awt.Container.processEvent(Container.java:1164)
- java.awt.Component.dispatchEventImpl(Component.java:2595)
- java.awt.Container.dispatchEventImpl(Container.java:1213)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
- java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
- java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
- java.awt.Container.dispatchEventImpl(Container.java:1200)
- java.awt.Window.dispatchEventImpl(Window.java:912)
- java.awt.Component.dispatchEvent(Component.java:2499)
- java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
- java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
- java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
- java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
(Review ID: 106859)
======================================================================