Dimension dv = viewport.getViewSize();
Dimension de = viewport.getExtentSize();
String command = ae.getActionCommand();
if (command == NORTH) {
if (p.y > 9) {
p.y -= 10;
}
}
else if (command == SOUTH) {
if (p.y + de.height < dv.height) {
p.y += 10;
}
}
else if (command == EAST) {
if (p.x + de.width < dv.width) {
p.x += 10;
}
}
else if (command == WEST) {
if (p.x > 9) {
p.x -= 10;
}
}
viewport.setViewPosition(p);