JDK-4530087 : JCK14/13a,interactive: api/java_awt/interactive/FileDialogTests.html#FileDialogT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2001-11-21
  • Updated: 2001-12-12
  • Resolved: 2001-12-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 rc1Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
JDK            : jdk1.4.0-build 86
JCK            : JCK1.4-b12, JCK13.a
Platform[s]    : Windows XP Professional, win2000
switch/mode    : -Xmixed -Xfuture
JCK test owner : http://javaweb.eng/jck/usr/owners.jto
Failing Test   : api/java_awt/interactive/FileDialogTests.html#FileDialogTests

If any file in awt.FileDialog is selected via mouse double-click,
FileDialog passes last mouse click to the parent window.

Test source location:
=====================
/net/jdk/export/disk8/local.java/jck1.4/JCK-runtime-14/tests/api/java_awt/interactive/FileDialogTests.java
/net/jdk/export/disk8/local.java/jck1.4/JCK-runtime-14/tests/api/java_awt/interactive/FileDialogDisplayer.java

jtr file location:
==================
/net/jtgb4u4c.eng/export/sail15/results/merlin/b86/jck14/win32/winxppro/workDir/api-interactive/api/java_awt/interactive/FileDialogTests_FileDialogTests.jtr

How to reproduce:
=================
1. Run the following script (probably, you may need to change JCK and JAVA_HOME paths)
2. Press "Activate" button to bring up FileDialog
3. Adjust FileDialog position to make sure that at least one file name
in the FileDialog's list is placed exactly over the "Activate" button 
from the main test frame.
4. Double-click mouse on that file name.

You will see that FileDialog disappears but brings up again because of last click reaches "Activate" button.

--- Script start ---
#!/bin/sh
JAVA_HOME="c:/j2sdk1.4.0-rc"
JCK="i:/sail16/JCK/jck14/JCK-runtime-14"
export CLASSPATH="$JCK/classes;$JCK/javatest.jar"
executeClass="javasoft.sqe.tests.api.java.awt.interactive.FileDialog.FileDialogTests"
executeArgs="-TestCaseID FileDialogTest0005"
$JAVA_HOME/bin/java -Xfuture -Xmixed -showversion ${executeClass} ${executeArgs}
--- Script end ---

Test output:
============
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b86)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b86, mixed mode)

FileDialogTest0005: Failed. FileDialog test does NOT work as expected.
STATUS:Failed.tests: 1; failed: 1; first test case failure: FileDialogTest0005

Specific Machine Info:
=====================
Hostname: jck-win2000xp
OS: Windows XP Professional

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-rc1 FIXED IN: merlin-rc1 INTEGRATED IN: merlin-rc1 VERIFIED IN: merlin-rc1
14-06-2004

SUGGESTED FIX ------- awt_Button.cpp ------- *** /tmp/sccs.c9aa9C Mon Nov 26 16:01:47 2001 --- awt_Button.cpp Mon Nov 26 15:58:44 2001 *************** *** 32,37 **** --- 32,38 ---- */ AwtButton::AwtButton() { + leftButtonDown = FALSE; } /* System provided button class */ *************** *** 119,134 **** } MsgRouting AwtButton::WmMouseUp(UINT flags, int x, int y, int button) { MsgRouting mrResult = AwtComponent::WmMouseUp(flags, x, y, button); ! POINT p = {x, y}; ! RECT rect; ! ::GetClientRect(GetHWnd(), &rect); ! if (::PtInRect(&rect, p) && button == LEFT_BUTTON) { ! WmNotify(BN_CLICKED); } return mrResult; --- 120,155 ---- } MsgRouting + AwtButton::WmMouseDown(UINT flags, int x, int y, int button) + { + // 4530087: keep track of the when the left mouse button is pressed + if (button == LEFT_BUTTON) { + leftButtonDown = TRUE; + } + return AwtComponent::WmMouseDown(flags, x, y, button); + } + + MsgRouting AwtButton::WmMouseUp(UINT flags, int x, int y, int button) { MsgRouting mrResult = AwtComponent::WmMouseUp(flags, x, y, button); ! // 4530087: It is possible that a left mouse press happened on a Window ! // obscuring this AwtButton, and during event handling the Window was ! // removed. This causes a WmMouseUp call to this AwtButton, even though ! // there was no accompanying WmMouseDown. ActionEvents should ONLY be ! // notified (via WmNotify() call) if the left button press happened on this ! // AwtButton. --bchristi ! if (button == LEFT_BUTTON && leftButtonDown) { ! leftButtonDown = FALSE; ! POINT p = {x, y}; ! RECT rect; ! ::GetClientRect(GetHWnd(), &rect); ! ! if (::PtInRect(&rect, p)) { ! WmNotify(BN_CLICKED); ! } } return mrResult; ------- awt_Button.h ------- *** /tmp/sccs.d9aa9C Mon Nov 26 16:01:47 2001 --- awt_Button.h Mon Nov 26 15:22:26 2001 *************** *** 33,38 **** --- 33,39 ---- static AwtButton* Create(jobject self, jobject hParent); /* Windows message handler functions */ + MsgRouting WmMouseDown(UINT flags, int x, int y, int button); MsgRouting WmMouseUp(UINT flags, int x, int y, int button); MsgRouting WmNotify(UINT notifyCode); MsgRouting OwnerDrawItem(UINT ctrlId, DRAWITEMSTRUCT far& drawInfo); *************** *** 39,44 **** --- 40,49 ---- MsgRouting WmPaint(HDC hDC); MsgRouting HandleEvent(MSG *msg, BOOL synthetic); + + private: + // 4530087: variable to keep track of left mouse press + BOOL leftButtonDown; }; #endif // AWT_BUTTON_H
11-06-2004

EVALUATION Look into for Merlin ###@###.### 2001-11-20 I thought this might be fixed along with 4509045, but it wasn't. I can reproduce it in the AWT PIT workspace, which was integrated into build 87. ###@###.### 2001-11-20 The problem is reproducible all the way back to merlin-b64 (the oldest build I can find) on Windows 2000. Strcitly speaking, the problem is not with what the JCK test is testing. The JCK1.4 test won't run under 1.3.1 (at least not easily), so I'm presently trying to get a test case that will fail under 1.4 and at least run under 1.3.1. ###@###.### 2001-11-21 The following test case reproduces the problem: // Test double-clicking of file in FileDialog, and passing of clicks to // underlying Components import java.awt.*; import java.awt.event.*; public class BFDTest extends MouseAdapter implements ActionListener { static Button showBtn; static Button listBtn; static BFDTest ml = new BFDTest(); static Frame f; public BFDTest() {} public static void main(String[] args) { f = new Frame("BFDTest"); showBtn = new Button("Show File Dialog"); listBtn = new Button("This button listens for mouse events"); showBtn.addActionListener(ml); listBtn.addActionListener(ml); listBtn.addMouseListener(ml); f.setLayout(new GridLayout(2,1)); f.setSize(400,400); f.add(showBtn); f.add(listBtn); f.show(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == showBtn) { FileDialog fd = new FileDialog(f); fd.show(); } else if (e.getSource() == listBtn) { System.out.println("actionPerformed"); } } public void mouseClicked(MouseEvent e) { System.out.println("mouseClicked, clickCount = " + e.getClickCount()); } public void mousePressed(MouseEvent e) { System.out.println("mousePressed"); } public void mouseReleased(MouseEvent e) { System.out.println("mouseReleased"); } } --- Under both 1.4 and 1.3.1, the underlying button receives a MOUSE_RELEASED event when the FileDialog is double-clicked. However, only 1.4 sends an ActionEvent. Under Solaris, no MOUSE_RELEASED is sent to the button underneath the FileDialog. ###@###.### 2001-11-21 I strongly suspect delta 1.36 of awt_Button.cpp, which fixed 4327679 and added the following function: MsgRouting AwtButton::WmMouseUp(UINT flags, int x, int y, int button) { MsgRouting mrResult = AwtComponent::WmMouseUp(flags, x, y, button); POINT p = {x, y}; RECT rect; ::GetClientRect(GetHWnd(), &rect); if (::PtInRect(&rect, p) && button == LEFT_BUTTON) { WmNotify(BN_CLICKED); } return mrResult; } For a mouse release (including those which began in a FileDialog), WmNotify(BN_CLICKED) is called, which sends the offending ActionEvent. I need to track down merlin-b31 to confirm. ###@###.### 2001-11-21 My test has uncovered another problem - it's possible for a Button to send TWO ActionEvents for one button press. Hold down the left and right mouse buttons on a java.awt.Button. Then, release the left button. The Button's ActionListener will be called twice. I suspect WmNotify is being called twice - once by Windows, and again from WmMouseUp. Perhaps a problem w/ mouse capture. ###@###.### 2001-11-21 The problem is that WmNotify() is called for the left button release even though the left button press happened on a different Component (the FileDialog, in this case). The simplest fix is to keep track of whether or not the left button was pressed on the AwtButton. If not, do not call WmNotify(). See the suggested fix. ###@###.### 2001-11-26
26-11-2001