有到screen的转换函数,我忘了。

解决方案 »

  1.   

    Class Transformer 的toScreen(double windowX, double windowY)
      

  2.   

    你要得到整个桌面上的坐标?
    还是相对于容器控件的?
    后者用
    SwingUtilities.convertPoint(thisComponent,e.getPoint(),thatComponent);
    thisComponent:可以是任意的控件,当然可以是button,你调用时可以用this代替。
    thatComponent:你要转换的环境坐标,如果是父窗口,就用this.getParent()代替。
    e就是你的监听器响应处理函数中的事件参数。如果你要转换为屏幕坐标,我想可以用
    SwingUtilities.convertPointToScreen(Point,Component);
    转换回来可以用:
    SwingUtilities.convertPointFromScreen(Point,Component);Hope you solve it! Good luck!