-
Bug
-
Resolution: Fixed
-
P2
-
1.0, 1.1
-
None
-
1.1fcs
-
x86, sparc
-
solaris_2.5, windows_95
-
Not verified
Name: el35337 Date: 01/14/97
When you double click on a file in
a FileDialog, the second click is sent to the
component positioned underneath the dialog at the
position of the cursor. The dialog should consume
the mouse clicks and disappear.
The following stand-alone program illustrates the
problem. It brings up a window which shows a
number in the lower right hand corner. The number
is incremented each time it detects a MOUSE_PRESSED
event. If you hit the 'd' key on the keyboard a
FileDialog will pop up. Double click on one of the
files in the dialog. The dialog will disappear, as
usual, and the click count will increment. The
panel under the FileDialog receives a MOUSE_PRESSED
and a MOUSE_RELEASED event when the user double
clicks on a file in the dialog.
===================================================
import java.awt.*;
import java.awt.event.*;
class Test
// ====
{
public static void main (String args[])
// ----
{
MyFrame frame = new MyFrame();
frame.show();
}
} // end Test class
class MyFrame extends Frame
// =======
{
public MyFrame ()
// -------
{
super("Test frame");
enableEvents(AWTEvent.WINDOW_EVENT_MASK |
AWTEvent.KEY_EVENT_MASK);
Panel panel = new MyPanel();
setSize(800, 600);
add("Center", panel);
}
public boolean processKeyEvent (KeyEvent e)
// ---------------
{
if (e.getId() == KeyEvent.KEY_TYPED)
if (e.getKeyChar() == 'd')
{
FileDialog dialog = new FileDialog(this);
dialog.show();
}
return super.processKeyEvent(e);
}
public void processWindowEvent (WindowEvent e)
// ------------------
{
if (e.getId() == WindowEvent.WINDOW_CLOSING)
{
dispose();
System.exit(0);
}
}
} // end myFrame
class MyPanel extends Panel
// =======
{
int clickCount;
public MyPanel ()
// -------
{
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
clickCount = 0;
}
public boolean processMouseEvent (MouseEvent e)
// -----------------
{
if (e.getId() == MouseEvent.MOUSE_PRESSED)
{
clickCount++;
repaint();
}
return super.processMouseEvent(e);
}
public void paint (Graphics g)
// -----
{
g.setFont(new Font("Dialog", Font.BOLD, 36));
g.drawString((new Integer(clickCount)).toString(), 700, 550);
}
} // end MyPanel
===================================================
Gray Matter Software, Inc. ###@###.###
======================================================================
- duplicates
-
JDK-1243013 FileDialog passes extra mousedown
-
- Closed
-