Search in sources :

Example 36 with HeadlessException

use of java.awt.HeadlessException in project bigbluebutton by bigbluebutton.

the class ScreenCapture method getMouseLocation.

private Point getMouseLocation() {
    PointerInfo pInfo;
    Point pointerLocation = new Point(0, 0);
    try {
        pInfo = MouseInfo.getPointerInfo();
    } catch (HeadlessException e) {
        pInfo = null;
    } catch (SecurityException e) {
        pInfo = null;
    }
    if (pInfo == null)
        return pointerLocation;
    return pInfo.getLocation();
}
Also used : PointerInfo(java.awt.PointerInfo) HeadlessException(java.awt.HeadlessException) Point(java.awt.Point)

Example 37 with HeadlessException

use of java.awt.HeadlessException in project GNS by MobilityFirst.

the class ReplicaLatencyTest method main.

/**
   * The main routine run from the command line.
   *
   * @param args
   * @throws Exception
   */
public static void main(String[] args) throws Exception {
    try {
        CommandLine parser = initializeOptions(args);
        if (parser.hasOption("help") || args.length == 0) {
            printUsage();
            System.exit(1);
        }
        String alias = parser.getOptionValue("alias");
        String host = parser.getOptionValue("host");
        String port = parser.getOptionValue("port");
        boolean debug = parser.hasOption("debug");
        String closeActiveReplica = parser.getOptionValue("closeAR");
        ReplicaLatencyTest test = new ReplicaLatencyTest(alias, host, port);
        // Need this on to read the which replica is responding
        //client.setEnableInstrumentation(true);
        test.findSlowGuid(closeActiveReplica);
        // send the reads and writes
        test.readsAndWrites(closeActiveReplica);
        //test.removeSubGuid();
        client.close();
        System.exit(0);
    } catch (HeadlessException e) {
        System.out.println("When running headless you'll need to specify the host and port on the command line");
        printUsage();
        System.exit(1);
    }
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) HeadlessException(java.awt.HeadlessException) RandomString(edu.umass.cs.gnscommon.utils.RandomString)

Example 38 with HeadlessException

use of java.awt.HeadlessException in project GNS by MobilityFirst.

the class CreateGuidTest method main.

/**
   * The main routine run from the command line.
   *
   * @param args
   * @throws Exception
   */
public static void main(String[] args) throws Exception {
    try {
        CommandLine parser = initializeOptions(args);
        if (parser.hasOption("help") || args.length == 0) {
            printUsage();
            System.exit(1);
        }
        String alias = parser.getOptionValue("alias");
        new CreateGuidTest(alias != null ? alias : ACCOUNT_ALIAS);
        System.exit(0);
    } catch (HeadlessException e) {
        System.out.println("When running headless you'll need to specify the host and port on the command line");
        printUsage();
        System.exit(1);
    }
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) HeadlessException(java.awt.HeadlessException) RandomString(edu.umass.cs.gnscommon.utils.RandomString)

Example 39 with HeadlessException

use of java.awt.HeadlessException in project GNS by MobilityFirst.

the class UserAuthPubKey method main.

/**
   *
   * @param arg
   */
public static void main(String[] arg) {
    try {
        JSch jsch = new JSch();
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle("Choose your privatekey(ex. ~/.ssh/id_dsa)");
        chooser.setFileHidingEnabled(false);
        int returnVal = chooser.showOpenDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            System.out.println("You chose " + chooser.getSelectedFile().getAbsolutePath() + ".");
            //			 , "passphrase"
            jsch.addIdentity(//			 , "passphrase"
            chooser.getSelectedFile().getAbsolutePath());
        }
        String host = null;
        if (arg.length > 0) {
            host = arg[0];
        } else {
            host = JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name") + "@localhost");
        }
        String user = host.substring(0, host.indexOf('@'));
        host = host.substring(host.indexOf('@') + 1);
        Session session = jsch.getSession(user, host, 22);
        // username and passphrase will be given via UserInfo interface.
        UserInfo ui = new UserInfoPrompted();
        session.setUserInfo(ui);
        session.connect();
        Channel channel = session.openChannel("shell");
        channel.setInputStream(System.in);
        channel.setOutputStream(System.out);
        channel.connect();
    } catch (HeadlessException | JSchException e) {
        System.out.println(e);
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) JFileChooser(javax.swing.JFileChooser) UserInfoPrompted(edu.umass.cs.aws.networktools.UserInfoPrompted) HeadlessException(java.awt.HeadlessException) Channel(com.jcraft.jsch.Channel) UserInfo(com.jcraft.jsch.UserInfo) JSch(com.jcraft.jsch.JSch) Session(com.jcraft.jsch.Session)

Example 40 with HeadlessException

use of java.awt.HeadlessException in project jdk8u_jdk by JetBrains.

the class RasterPrinterJob method printDialog.

/**
     * Presents the user a dialog for changing properties of the
     * print job interactively.
     * @returns false if the user cancels the dialog and
     *          true otherwise.
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
     * returns true.
     * @see java.awt.GraphicsEnvironment#isHeadless
     */
public boolean printDialog() throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
    attributes.add(new Copies(getCopies()));
    attributes.add(new JobName(getJobName(), null));
    boolean doPrint = printDialog(attributes);
    if (doPrint) {
        JobName jobName = (JobName) attributes.get(JobName.class);
        if (jobName != null) {
            setJobName(jobName.getValue());
        }
        Copies copies = (Copies) attributes.get(Copies.class);
        if (copies != null) {
            setCopies(copies.getValue());
        }
        Destination dest = (Destination) attributes.get(Destination.class);
        if (dest != null) {
            try {
                mDestType = RasterPrinterJob.FILE;
                mDestination = (new File(dest.getURI())).getPath();
            } catch (Exception e) {
                mDestination = "out.prn";
                PrintService ps = getPrintService();
                if (ps != null) {
                    Destination defaultDest = (Destination) ps.getDefaultAttributeValue(Destination.class);
                    if (defaultDest != null) {
                        mDestination = (new File(defaultDest.getURI())).getPath();
                    }
                }
            }
        } else {
            mDestType = RasterPrinterJob.PRINTER;
            PrintService ps = getPrintService();
            if (ps != null) {
                mDestination = ps.getName();
            }
        }
    }
    return doPrint;
}
Also used : Destination(javax.print.attribute.standard.Destination) HeadlessException(java.awt.HeadlessException) Copies(javax.print.attribute.standard.Copies) JobName(javax.print.attribute.standard.JobName) File(java.io.File) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrinterAbortException(java.awt.print.PrinterAbortException) HeadlessException(java.awt.HeadlessException) PrintException(javax.print.PrintException) PrinterException(java.awt.print.PrinterException) IOException(java.io.IOException) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) PrintService(javax.print.PrintService) StreamPrintService(javax.print.StreamPrintService)

Aggregations

HeadlessException (java.awt.HeadlessException)63 IOException (java.io.IOException)19 File (java.io.File)16 Point (java.awt.Point)8 GraphicsConfiguration (java.awt.GraphicsConfiguration)7 BufferedImage (java.awt.image.BufferedImage)7 Dimension (java.awt.Dimension)6 Rectangle (java.awt.Rectangle)6 ActionEvent (java.awt.event.ActionEvent)5 PrintService (javax.print.PrintService)5 StreamPrintService (javax.print.StreamPrintService)5 JFrame (javax.swing.JFrame)5 GraphicsDevice (java.awt.GraphicsDevice)4 GraphicsEnvironment (java.awt.GraphicsEnvironment)4 PrinterException (java.awt.print.PrinterException)4 DialogTypeSelection (javax.print.attribute.standard.DialogTypeSelection)4 ImageIcon (javax.swing.ImageIcon)4 JFileChooser (javax.swing.JFileChooser)4 Frame (java.awt.Frame)3 Graphics (java.awt.Graphics)3