JDK-4854950 : JFrame's decorated root pane doesn't like MouseListeners
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.2,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2003-04-28
  • Updated: 2006-03-01
  • Resolved: 2006-02-16
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.
JDK 6
6 b72Fixed
Related Reports
Relates :  
Description
Name: rmT116609			Date: 04/28/2003


FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)

java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)

FULL OS VERSION :
glibc-2.2.4-25mdk
Kernel: Linux  2.4.18-6mdk #1 Fri Mar 15 02:59:08 CET 2002
i686 unknown
  Release: Mandrake Linux release 8.2 (Bluebird) for i586

A DESCRIPTION OF THE PROBLEM :
If either a MouseListener or MouseMotionListener is added to a JFrame's root pane, then the frame decoration will not move or resize the window nor will the pointer change icon. Only applies if the root pane is supplying the frame decoration. Does not apply to JInternalFrame, irrespective of whether listener is added to the internal or external frame root pane.

Tested on Metal PL&F. CDE/Motif and GTK PL&Fs do not appear to support this feature.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;

class FrameBug {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setUndecorated(true);
        frame.getRootPane().setWindowDecorationStyle(
            javax.swing.JRootPane.FRAME
        );
        // Either of the next two lines will do.
        frame.getRootPane().addMouseListener(new MouseAdapter() {});
        //frame.getRootPane().addMouseMotionListener(new MouseMotionAdapter() {});
        frame.pack();
        frame.setVisible(true);
    }
}

---------- END SOURCE ----------
(Review ID: 184904) 
======================================================================

Comments
EVALUATION see #6491619
16-12-2008

EVALUATION The fix was backed out from both JDK 7 and 6
16-12-2008

EVALUATION This fix resulted in the regression 6491619. I'm removing this fix from 7 and 6u1.
22-11-2006

EVALUATION A discussion on this bug and suggested fix can be found at http://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=10872 .
13-01-2006

EVALUATION This is happening because of how events are dispatched. AWT dispatches events to the deepest component over the mouse that has mouse listeners (or mouse events enabled). MetalRootPaneUI installs mouse listeners on the window to resize the window. When you install mouse listeners on the rootpane the rootpane becomes a valid target for the mouse events and the window no longer sees them. To fix this we need to start adding listeners to the RootPane too, that way MetalRootPaneUI will get the events and can handle the resize and other mouse related things.
26-07-2005

EVALUATION Strange. We should be able to add more than one mouse listener to the root pane. More investigation needed. ###@###.### 2003-05-05
05-05-2003