Description: 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
To Search:
File list (Check if you may need any files):
Java抓不住的方块\MouseTrack.class
................\MouseTrack.html
................\MouseTrack.java
................\_desktop.ini
................\抓不住的方块.doc
Java抓不住的方块