JDK-4398733 : MouseClicked event not delivered when switched between 2 Internal frames
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2,1.3.0,1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,windows_nt,windows_2000,windows_xp generic,windows_nt,windows_2000,windows_xp
  • CPU: generic,x86
  • Submitted: 2000-12-15
  • Updated: 2005-10-18
  • Resolved: 2005-08-03
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 b46Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Name: yyT116575			Date: 12/15/2000


java version 1.3.0
Runtime Environment Standard Edition bulid 1.3.0-C, mixed mode
java Hotspot client vm build 1.3.0-c, mixed mode



mouseClicked Event are not delivered when 2 Internal frames are involved and
when we select a component in the internal frame which didn't have the focus..
To Reproduce the problem, Compile and run the following program..Select a node
on Frame 1 and then select a node on Frame 2. You will see the Console Output as

Tree 1 : Mouse Pressed
Tree 1 : Mouse Released
Tree 1 : Mouse Clicked
Tree 2 : Mouse Pressed
Tree 2 : Mouse Released

As u can see although the mousePressed and mouseReleased events were recived
mouseClicked was not received for the Tree2..

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

public class ClickTest extends JFrame implements MouseListener {

  JTree tree1;
  JTree tree2;

  public ClickTest() {
    super();
    Vector vector1 = new Vector();
    vector1.add("Hello1");
    vector1.add("Hi1");
    Vector vector2 = new Vector();
    vector2.add("Hello2");
    vector2.add("Hi2");
    tree1 = new JTree(vector1);
    tree2 = new JTree(vector2);
    tree1.addMouseListener(this);
    tree2.addMouseListener(this);
    JInternalFrame iFrame1 = new JInternalFrame("Frame 1");
    JInternalFrame iFrame2 = new JInternalFrame("Frame 2");
    JDesktopPane pane = new JDesktopPane();
    iFrame1.getContentPane().add(tree1);
    iFrame2.getContentPane().add(tree2);
    iFrame1.pack();
    iFrame2.pack();
    iFrame1.setSize(200,200);
    iFrame2.setSize(200,200);
    pane.add(iFrame1);
    pane.add(iFrame2);
    iFrame1.show();
    iFrame2.show();
    getContentPane().add(pane);
    pack();
    setSize(400,400);
    show();
  }

  public void mousePressed(MouseEvent e) {
    if (e.getSource() == tree1) {
      System.out.println("Tree 1 : Mouse Pressed");
    }
    if (e.getSource() == tree2) {
      System.out.println("Tree 2 : Mouse Pressed");
    }
  }

  public void mouseReleased(MouseEvent e) {
    if (e.getSource() == tree1) {
      System.out.println("Tree 1 : Mouse Released");
    }
    if (e.getSource() == tree2) {
      System.out.println("Tree 2 : Mouse Released");
    }
  }

  public void mouseClicked(MouseEvent e) {
    if (e.getSource() == tree1) {
      System.out.println("Tree 1 : Mouse Clicked");
    }
    if (e.getSource() == tree2) {
      System.out.println("Tree 2 : Mouse Clicked");
    }
  }

  public void mouseEntered(MouseEvent e) {};

  public void mouseExited(MouseEvent e) {};

  public static void main(String[] args) {
    new ClickTest();
  }
}
(Review ID: 113817) 
======================================================================

Comments
EVALUATION This problem is a little more complicated than it appears. When an internal frame gets selected it is moved to the front of the desktop. This moveToFront call first removes the internal frame from its current layer and then places it on the topmost layer. The problem is with the ordering of the events. 1. MOUSE_PRESSED event is sent to the internal frame. 2. internal frame is removed from layered pane. 3. Unwanted MOUSE_EXITED event is sent. 4. internal frame is added to the layered pane. 5. Unwanted MOUSE_ENTERED event is sent. 6. We don't get our MOUSE_CLICKED event. :( joutwate@eng 2001-01-11 Installed AWTEventListener to listen for mouse press events and activate the frame. Made glasspane not visible. Removed creation of glassPaneDispatcher so it no longer listens for events. ###@###.### 2005-06-01 23:28:50 GMT
01-06-2005