Hello awt-dev,
 
Bug 6840067 has been marked as Closed-Not Reproducible and I would like to get 
the issue reopened.  Attached is a test case that explains "The when and why 
the PointerInfo becomes null."  The test case is a modified copy of the 
MouseInfo.getPointerInfo.  To reproduce the error you need a workstation with 
multiple displays that are dependent.  In my case a windows vista machine with 
2 monitors.  Run the test case and then lock the desktop of the workstation.  
When you log back in to the machine the test fails because the mouse point is 
not contained in any of the graphics configurations.  This causes the 
PointerInfo to be null, and Component.getMousePosition does not handle this 
case.
 
Jason                                     
package mil.army.osc.cntr.mcbride.mtms.cs.gui;

import org.junit.Test;
import static org.junit.Assert.*;
import java.awt.*;
import java.awt.peer.*;
import java.lang.reflect.*;

/**
 * Run this test and lock your desktop.
 *
 * java.awt.Point[x=21680584,y=0]  <------- not contained in and GC.
 *   Win32GraphicsDevice[screen=0]
 * 
sun.awt.Win32GraphicsConfig@2e273686[dev=Win32GraphicsDevice[screen=0],pixfmt=0]
 * java.awt.Rectangle[x=0,y=0,width=1680,height=1050]
 * Win32GraphicsDevice[screen=1]
 * 
sun.awt.Win32GraphicsConfig@1ebcda2d[dev=Win32GraphicsDevice[screen=1],pixfmt=0]
 * java.awt.Rectangle[x=1680,y=0,width=1680,height=1050]
 * @author Jason Mehrens
 */
public class Bug6840067 {

    private static final Method getPeer;
    private static final Method fillPoint;

    static {
        try {
            getPeer = Toolkit.class.getDeclaredMethod("getMouseInfoPeer");
            getPeer.setAccessible(true);

            fillPoint = 
MouseInfoPeer.class.getDeclaredMethod("fillPointWithCoords", Point.class);
            fillPoint.setAccessible(true);
        } catch (Exception e) {
            throw new java.lang.ExceptionInInitializerError(e);
        }
    }

    public Bug6840067() {
    }

    /**
     * See java.awt.MouseInfo.getPointerInfo()
     * @throws Exception
     */
   @Test
    public void mouseTest() throws Exception {
        Point point = new Point(0, 0);
        GraphicsDevice[] gds = null;
        int deviceNum;
        while (true) {
            boolean found = false;
            Object peer = getPeer.invoke(Toolkit.getDefaultToolkit());
            deviceNum = (Integer) fillPoint.invoke(peer, point);
            gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
                    getScreenDevices();
            for (int i = 0; i < gds.length; i++) {
                GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
                Rectangle bounds = gc.getBounds();
                if (bounds.contains(point)) {
                    found = true;
                    break;
                }
            }

            if (!found) { //this is not covered
                break;
            }
        }

        System.out.println(deviceNum);
        System.out.println(point);
        for (int i = 0; i < gds.length; i++) {
            GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
            Rectangle bounds = gc.getBounds();
            System.out.println(gds[i]);
            System.out.println(gc);
            System.out.println(bounds);
        }

        fail(point.toString());
    }
}

Reply via email to