/* * Copyright 2005-2008 Kirill Grouchnikov, based on work by * Sun Microsystems, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package docrobot; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import javax.swing.*; import org.fest.swing.core.Robot; import org.fest.swing.edt.*; import org.fest.swing.timing.Condition; import org.fest.swing.timing.Pause; import org.jdesktop.swingx.JXErrorPane; import org.jdesktop.swingx.error.ErrorInfo; import org.pushingpixels.substance.api.SubstanceLookAndFeel; import org.pushingpixels.substance.api.SubstanceSkin; /** * The base class for taking a single screenshot for Substance documentation. * * @author Kirill Grouchnikov */ public class ErrorPaneRobot { /** * The associated Substance skin. */ protected SubstanceSkin skin; /** * The screenshot filename. */ protected String screenshotFilename; protected JDialog dialog; protected Robot robot; /** * Creates the new screenshot robot. * * @param skin * Substance skin. * @param screenshotFilename * The screenshot filename. */ public ErrorPaneRobot(SubstanceSkin skin, String screenshotFilename, Robot robot) { this.skin = skin; this.screenshotFilename = screenshotFilename; this.robot = robot; } /** * Runs the screenshot process. */ public void run() { long start = System.currentTimeMillis(); // set the skin GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { SubstanceLookAndFeel.setSkin(skin); JDialog.setDefaultLookAndFeelDecorated(true); } }); robot.waitForIdle(); final Frame owner = GuiActionRunner.execute(new GuiQuery() { @Override protected Frame executeInEDT() throws Throwable { return JOptionPane.getRootFrame(); } }); // show dialog GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { try { URL url = new URL("some wrong URL string"); } catch (MalformedURLException murle) { String msg = "An error just happened. Possible reasons:" + "