* Runs the screenshot process.
*/
public void run() {
long start = System.currentTimeMillis();
Robot robot = BasicRobot.robotWithNewAwtHierarchy();
// set skin
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
SubstanceLookAndFeel.setSkin(skin);
JFrame.setDefaultLookAndFeelDecorated(true);
}
});
robot.waitForIdle();
// create the frame and set the icon image
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
sf = new SampleFrame();
sf.setIconImage(SubstanceImageCreator.getColorSchemeImage(null,
new ImageIcon(SkinRobot.class.getClassLoader()
.getResource(
"test/resource/image-x-generic.png")),
SubstanceLookAndFeel.getCurrentSkin(sf.getRootPane())
.getActiveColorScheme(
DecorationAreaType.PRIMARY_TITLE_PANE),
0.0f));
sf.setSize(338, 245);
sf.setLocationRelativeTo(null);
sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sf.setVisible(true);
}
});
robot.waitForIdle();
// get the default button
JButton defaultButton = GuiActionRunner
.execute(new GuiQuery<JButton>() {
@Override
protected JButton executeInEDT() throws Throwable {
return sf.getRootPane().getDefaultButton();
}
});
// and move the mouse to it
robot.moveMouse(defaultButton);
robot.waitForIdle();
// wait for a second
Pause.pause(1000);
// make the first screenshot
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
makeScreenshot(1);
}
});
robot.waitForIdle();
// switch to the last tab
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
sf.switchToLastTab();
}
});
robot.waitForIdle();
// move the mouse away from the frame
robot.moveMouse(new Point(0, 0));
robot.waitForIdle();
// wait for two seconds
Pause.pause(1000);
// make the second screenshot
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
makeScreenshot(2);
}
});
robot.waitForIdle();
// dispose the frame
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
sf.dispose();
}
});
robot.waitForIdle();
long end = System.currentTimeMillis();
System.out.println(this.getClass().getSimpleName() + " : "
+ (end - start) + "ms");
}