Description: Programming ideas: first, to make this exercise because the instance box not catch, so first of all to make the interface box, first set the box through the Graphics class object function g.setColor (Color.red) color is red, then By 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, thus completing the box production. Then, in order to achieve " catch box" effect, so to respond to mouse events, through the function public boolean mouseDown (java.awt.Event evt, int x, int y in response to pressing the mouse moves the cursor position to judge by Avoid mouse caught in the interface box.
To Search:
File list (Check if you may need any files):
练习97抓不住的方块\MouseTrack.class
..................\MouseTrack.html
..................\MouseTrack.java
..................\_desktop.ini
..................\练习96抓不住的方块.doc
练习97抓不住的方块