01: package abbot.tester.extensions;
02:
03: import java.awt.*;
04: import java.awt.event.InputEvent;
05: import example.ArrowButton;
06:
07: /** Provide user actions and identifiers for the {@link ArrowButton}
08: component. */
09:
10: public class ArrowButtonTester extends abbot.tester.ComponentTester {
11:
12: /** Set up the editor menu documentation properties. */
13: static {
14: System.setProperty("actionRoll.menu", "Roll");
15: System.setProperty("actionRoll.desc",
16: "Hold down the arrow button");
17: System.setProperty("ArrowButtonTester.actionRoll.args",
18: "actionRoll(Component comp, int ms)");
19: }
20:
21: // NOTE: while deprecated, there is not currently in place a replacement
22: // for noting one or more unique attributes of custom components, so for
23: // now, this will do, but you are restricted to a single tag.
24: public String deriveTag(Component comp) {
25: return ((ArrowButton) comp).getDirection();
26: }
27:
28: /** Press and hold the button for the given length of time (in ms). */
29: public void actionRoll(Component comp, int ms) {
30: Dimension size = comp.getSize();
31: mousePress(comp, (size.width + 1) / 2, (size.height + 1) / 2,
32: InputEvent.BUTTON1_MASK);
33: delay(ms);
34: mouseRelease(InputEvent.BUTTON1_MASK);
35: }
36: }
|