CS 4773 Object Oriented Systems
Mover.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Mover extends Applet implements
MoveCallBack,
ActionListener,
AdjustmentListener,
MouseListener,
MouseMotionListener,
ComponentListener {
Button ClearButton;
Button MoveButton;
Button DirectionButton;
int rect_width = 50;
int rect_height = 20;
Color back_color = Color.yellow;
int delay = 100;
String msg = "This program was written by S. Robbins";
Scrollbar DelayValue;
Label DelayLabel;
Image buffer;
Graphics GC;
Graphics GCback;
int width;
int height;
Point mouse_down;
int mouse_current_x;
int mouse_current_y;
boolean mouse_down_flag = false;
boolean forward_flag = true;
Vector rectangles;
public void init() {
setup_layout();
setup_images();
rectangles = new Vector();
update_image();
addMouseListener(this);
addMouseMotionListener(this);
addComponentListener(this);
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
synchronized(this) {
g.drawImage(buffer,0,0,this);
}
if (mouse_down_flag) {
g.setColor(Color.black);
g.drawLine(mouse_down.x,mouse_down.y,mouse_current_x,mouse_current_y);
}
}
public void stop() {
stop_all();
}
public void start() {
}
private void stop_all() {
RectLineMove R;
for (int i=0;i