文件名称:mousetrack
介绍说明--下载内容来自于网络,使用问题请自行百度
知识点:使用Graphics类制作方块,使用java.awt.Event类响应鼠标动作,使用Color类设置方块的颜色,使用int类记录光标的位置。
实现思路:首先要制作界面中的方块,通过Graphics类的对象函数g.setColor(Color.red)设置方块的颜色为红色,然后通过语句g.drawRect(0, 0, size().width - 1, size().height - 1)和g.drawRect(mx, my, (size().width/10) - 1, (size().height/10) - 1)绘制出两个矩形,完成方块的制作。然后实现“抓不住的方块”效果,要响应鼠标事件,通过函数public boolean mouseDown(java.awt.Event evt, int x, int y响应按下鼠标的动作,通过光标位置的判断来避免鼠标抓到界面中的方块-Knowledge: Use the Graphics class production box, use java.awt.Event class response to mouse movements, using color Color class settings box, use the cursor position int class record.
Realization of ideas: First, to make the interface box, set the box through the Graphics class object function g.setColor (Color.red) color is red, then the statement g.drawRect (0, 0, size () width- 1. , size () height-. 1) and g.drawRect (mx, my, (size () .width/10)- 1, (size () .height/10)- 1) draw two rectangles, complete the box production. Then realize "box not catch" effect, to respond to mouse events, through the function public boolean mouseDown (java.awt.Event evt, int x, int y action in response to pressing the mouse, by judging the mouse cursor position to avoid grasping the interface box
实现思路:首先要制作界面中的方块,通过Graphics类的对象函数g.setColor(Color.red)设置方块的颜色为红色,然后通过语句g.drawRect(0, 0, size().width - 1, size().height - 1)和g.drawRect(mx, my, (size().width/10) - 1, (size().height/10) - 1)绘制出两个矩形,完成方块的制作。然后实现“抓不住的方块”效果,要响应鼠标事件,通过函数public boolean mouseDown(java.awt.Event evt, int x, int y响应按下鼠标的动作,通过光标位置的判断来避免鼠标抓到界面中的方块-Knowledge: Use the Graphics class production box, use java.awt.Event class response to mouse movements, using color Color class settings box, use the cursor position int class record.
Realization of ideas: First, to make the interface box, set the box through the Graphics class object function g.setColor (Color.red) color is red, then the statement g.drawRect (0, 0, size () width- 1. , size () height-. 1) and g.drawRect (mx, my, (size () .width/10)- 1, (size () .height/10)- 1) draw two rectangles, complete the box production. Then realize "box not catch" effect, to respond to mouse events, through the function public boolean mouseDown (java.awt.Event evt, int x, int y action in response to pressing the mouse, by judging the mouse cursor position to avoid grasping the interface box
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Java抓不住的方块/MouseTrack.class
Java抓不住的方块/MouseTrack.html
Java抓不住的方块/MouseTrack.java
Java抓不住的方块/_desktop.ini
Java抓不住的方块/抓不住的方块.doc
Java抓不住的方块
Java抓不住的方块/MouseTrack.html
Java抓不住的方块/MouseTrack.java
Java抓不住的方块/_desktop.ini
Java抓不住的方块/抓不住的方块.doc
Java抓不住的方块
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.