点击图片上不同的位置,响应不同的事件。

jspxnet 2002-01-07 02:34:48
就是一个图片,当多个按钮用。
不用JButton有什么好的方法。
...全文
127 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dtmark 2002-01-07
  • 打赏
  • 举报
回复
或者建几个不可见的JBUTTON然后在用一张大的背景···
即 透明的按钮
p9 2002-01-07
  • 打赏
  • 举报
回复
把图片切成几块不就可以了。
如果图片是动态生成的,就另当别论了
ge_yc 2002-01-07
  • 打赏
  • 举报
回复
同意
zych72 2002-01-07
  • 打赏
  • 举报
回复
使用MouseEvent.getPoint()取得相对位置,根据位置不同来执行不同的操作
public Point getPoint()
Returns the x,y position of the event relative to the source component.
Returns:
a Point object containing the x and y coordinates relative to the source component

--------------------------------------------------------------------------------
ebrmp 2002-01-07
  • 打赏
  • 举报
回复
如果是做的网页用HTML的MAP标签就解决问题了

62,614

社区成员

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

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