那你就郁闷吧,这个又不难的 public static Point getLocationOnScreen(MouseEvent e) { Container source = (Container)e.getSource(); Container parent = source.getParent(); Container win = null; int x = e.getX(); int y = e.getY();
while(parent != null) { x += parent.getX(); y += parent.getY(); win = parent; parent = parent.getParent(); }
if(win != null && win instanceof Window) { Rectangle desktopBounds = getDesktopBounds((Window)win); x += desktopBounds.x; y += desktopBounds.y; }
return new Point(x, y); } JDK6中对MouseEvent增加了getLocationOnScreen(),根本就不用自己写
楼主【skyhits1921】截止到2008-07-15 13:40:30的历史汇总数据(不包括此帖):
发帖的总数量:10 发帖的总分数:400 每贴平均分数:40
回帖的总数量:29 得分贴总数量:8 回帖的得分率:27%
结贴的总数量:6 结贴的总分数:200
无满意结贴数:2 无满意结贴分:130
未结的帖子数:4 未结的总分数:200
结贴的百分比:60.00 % 结分的百分比:50.00 %
无满意结贴率:33.33 % 无满意结分率:65.00 %
楼主加油
那你就郁闷吧,这个又不难的
public static Point getLocationOnScreen(MouseEvent e)
{
Container source = (Container)e.getSource();
Container parent = source.getParent();
Container win = null;
int x = e.getX();
int y = e.getY();
while(parent != null)
{
x += parent.getX();
y += parent.getY();
win = parent;
parent = parent.getParent();
}
if(win != null && win instanceof Window)
{
Rectangle desktopBounds = getDesktopBounds((Window)win);
x += desktopBounds.x;
y += desktopBounds.y;
}
return new Point(x, y);
}
JDK6中对MouseEvent增加了getLocationOnScreen(),根本就不用自己写
[email protected]