Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package samples;
- import java.awt.event.MouseEvent;
- import acm.graphics.GRect;
- import acm.program.*;
- public class GraphicsProgramSample extends GraphicsProgram {
- GRect rect = new GRect(200, 100);
- public void init() {
- addMouseListeners();
- }
- public void run() {
- add(rect, 200, 200);
- }
- public void mouseMoved(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- rect.setLocation(x, y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement