summaryrefslogtreecommitdiff
path: root/java/gjt/rubberband/RubberbandPanel.java
blob: e4c25f4efb576251f6db611d3f871c05670e93b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package gjt.rubberband;

import java.awt.*;

/**
 * An extension of Panel which is fitted with a Rubberband.  
 * Handling of mouse events is automatically handled for 
 * rubberbanding.<p>
 *
 * Clients may set or get the Rubberband at any time.<p>
 *
 * @version 1.0, Dec 27 1995
 * @author  David Geary
 * @see     Rubberband
 * @see     gjt.test.RubberbandTest
 */
public class RubberbandPanel extends Panel {
    private Rubberband rubberband;

    public void setRubberband(Rubberband rubberband) {
        this.rubberband = rubberband;
    }
    public Rubberband getRubberband() {
        return rubberband;
    }
    public boolean mouseDown(Event event, int x, int y) {
        rubberband.anchor(new Point(x,y));
        return false;
    }
    public boolean mouseDrag(Event event, int x, int y) {
        rubberband.stretch(new Point(x,y));
        return false;
    }
    public boolean mouseUp(Event event, int x, int y) {
        rubberband.end(new Point(x,y));
        return false;
    }
}