Example usage for java.awt HeadlessException getMessage

List of usage examples for java.awt HeadlessException getMessage

Introduction

In this page you can find the example usage for java.awt HeadlessException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this HeadlessException .

Usage

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Start video capture using VideoRecorder class
 * @param driverMode/*from w  ww  .  j  a v  a2  s  .c  om*/
 * @param gridConnector
 * @param videoName      name of the video to record so that it's unique. Only used locally. In remote, grid sessionId is used
 */
public static VideoRecorder startVideoCapture(DriverMode driverMode, SeleniumGridConnector gridConnector,
        File videoFolder, String videoName) {
    if (driverMode == DriverMode.LOCAL) {
        try {
            VideoRecorder recorder = new VideoRecorder(videoFolder, videoName);
            recorder.start();
            return recorder;
        } catch (HeadlessException e) {
            throw new ScenarioException(
                    "could not initialize video capture with headless robot: " + e.getMessage());
        }

    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.startVideoCapture();
        return new VideoRecorder(videoFolder, videoName, false);
    } else {
        throw new ScenarioException("driver supports captureDesktopToBase64String only in local and grid mode");
    }
}

From source file:ch.zhaw.iamp.rct.Controller.java

/**
 * Calculates the weights configured in {@link WeightsCalculatorWindow} and
 * writes the result to the also configure output file.
 */// w ww  .j  av a  2s . c  om
public void calculateWeights() {
    weightCalulation = new Thread() {
        @Override
        public void run() {

            try {
                long startTime = System.currentTimeMillis();

                Weights.calculateWeights(weightsCalculatorWindow.getSpringLengthsPath(),
                        weightsCalculatorWindow.getAnglesPath(), weightsCalculatorWindow.getOutputPath(),
                        weightsCalculatorWindow.getNumberOfOffsetSteps());

                weightsCalculatorWindow.configureGuiForCalculationPhase(false);
                JOptionPane.showMessageDialog(weightsCalculatorWindow,
                        "Calculation complete. The opartion took " + getDuration(startTime), "Complete",
                        JOptionPane.INFORMATION_MESSAGE);
            } catch (HeadlessException ex) {
                JOptionPane.showMessageDialog(weightsCalculatorWindow, "An error occurred: " + ex.getMessage(),
                        "Error", JOptionPane.ERROR_MESSAGE);
            }
        }

        private String getDuration(long startTime) {
            long durationInMilliseconds = System.currentTimeMillis() - startTime;
            long durationInSeconds = durationInMilliseconds / 1000;

            return durationInSeconds + " s";
        }
    };

    SwingUtilities.invokeLater(weightCalulation);
}

From source file:zsk.JFCMainClient.java

/** Interfaccia generale pubblica
 * @param args//from  www  .  java  2s.com
 * @param silentMode
 * @param downloadDir
 */
public static void fpInit(final String[] args, final boolean silentMode, final String downloadDir) {
    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            debugoutput("shutdown hook handler.");
            if (JFCMainClient.frame == null) {
                JFCMainClient.shutdownAppl();
            }
            debugoutput("shutdown hook handler. end run()");
        }
    });

    try { // load from file
        config = new XMLConfiguration(szConfigFile);
        debugoutput("configuration loaded from file: ".concat(config.getBasePath()));
        // create empty config entries?
    } catch (ConfigurationException e1) {
        debugoutput("configuration could not be load from file: ".concat(szConfigFile)
                .concat(" creating new one."));
        config = new XMLConfiguration();
    }

    JFCMainClient.saargs = args;
    if (args.length > 0) {
        bIsCLI = true;
        runCLI(silentMode, downloadDir);
    } else {
        try {
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (java.lang.InternalError ie) {
            System.err.println(ie.getMessage());
            printHelp();
            System.exit(1);
        }

        //         try {
        /*javax.swing.SwingUtilities.invokeAndWait(new Runnable() {   });*/
        guiThread = new Thread(new Runnable() {

            public void run() {
                try {
                    initializeUI(silentMode, downloadDir);
                    while (!guiThread.isInterrupted()) {
                    }
                } catch (java.awt.HeadlessException he) {
                    System.err.println(he.getMessage());
                    JFCMainClient.printHelp();
                    System.exit(1);
                }
            }

        });
        guiThread.start();
        //         } catch (InterruptedException e) {
        //            e.printStackTrace();
        //         } catch (InvocationTargetException e) {
        //            e.printStackTrace();
        //         }
    } // if
}