FileDocCategorySizeDatePackage
CompassScroller.javaAPI DocExample1182Tue Apr 08 09:17:32 BST 2003None

CompassScroller

public class CompassScroller extends Object implements ActionListener

Fields Summary
public static final String
NORTH
public static final String
SOUTH
public static final String
EAST
public static final String
WEST
private JViewport
viewport
private Point
p
Constructors Summary
public CompassScroller(JViewport viewport)


     
    this.viewport = viewport;
    p = new Point();
  
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent ae)

    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);