如何获得绝对坐标

thetm 2003-11-23 03:34:00
java中的获得坐标都是相对的,比如鼠标事件都是获得鼠标相对于加事件的空间的相对坐标,如何才能获得相对屏幕的绝对坐标呢?
...全文
87 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenr21c 2003-12-11
  • 打赏
  • 举报
回复
楼上用的都是swing的

awt该如何取绝对坐标?
cocosunshine 2003-11-27
  • 打赏
  • 举报
回复
x+getLocationOnScreen().x
y+getLocationOnScreen().y

yangjuanli 2003-11-27
  • 打赏
  • 举报
回复
没错,就是
x+getLocationOnScreen().x
y+getLocationOnScreen().y
这两个!!
wxh512 2003-11-26
  • 打赏
  • 举报
回复
同意楼上的
方法就是那两个看你怎么用了
aol_aog 2003-11-24
  • 打赏
  • 举报
回复
楼上的说的好象有点问吧?我想下面这个应该是解决的方法呀!
java.swing.SwingUtilities.convertPointToScreen(Point p, Component c);
Convert a point from a component's coordinate system to screen coordinates.

  Parameters:
  p - a Point object (converted to the new coordinate system)
  c - a Component object组件
wobelisk 2003-11-24
  • 打赏
  • 举报
回复
x+getLocationOnScreen().x
y+getLocationOnScreen().y
kunbone 2003-11-24
  • 打赏
  • 举报
回复
x+getLocationOnScreen().x
y+getLocationOnScreen().y
就这样试一试吧

好像没有什么问题呢??
longbaduo 2003-11-23
  • 打赏
  • 举报
回复
up

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧