Package java.awt

Examples of java.awt.Desktop


   {
      for (Resource<?> resource : dirs)
      {
         if (resource instanceof FileResource<?>)
         {
            Desktop dt = Desktop.getDesktop();
            try
            {
               dt.edit((File) resource.getUnderlyingResourceObject());
            }
            catch (UnsupportedOperationException e)
            {
               if (OSUtils.isLinux())
               {
View Full Code Here


        if (!Desktop.isDesktopSupported()) {
            download(component, object, streamId);
            return;
        }

        Desktop desktop = Desktop.getDesktop();

        if (!desktop.isSupported(Desktop.Action.OPEN)) {
            download(component, object, streamId);
            return;
        }

        File file = null;

        try {
            file = createTempFileFromDocument(object, streamId);
        } catch (Exception e) {
            showError(component, e);
        }

        try {
            desktop.open(file);
        } catch (Exception e) {
            if (e instanceof IOException) {
                copy(component, file);
            } else {
                showError(component, e);
View Full Code Here

                HtmlReport report = new HtmlReport();
                report.createReport(runner.getParameters(), runner.getGroups(), tempReportFile);

                // show report
                Desktop desktop = Desktop.getDesktop();
                if (!desktop.isSupported(Desktop.Action.OPEN)) {
                    JOptionPane.showMessageDialog(owner, "Report: " + tempReportFile.getAbsolutePath(), "Report",
                            JOptionPane.INFORMATION_MESSAGE);
                } else {
                    desktop.open(tempReportFile);
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(owner, "Error: " + e.getMessage(), "Report Error",
                        JOptionPane.ERROR_MESSAGE);
            } finally {
View Full Code Here

    helpLabel.setToolTipText("Help");
    helpLabel.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent arg0) {
        try {
          Desktop d = Desktop.getDesktop();
          d.browse(new URI("https://docs.google.com/document/d/1URv0ozD0kBYfDm3SmbY8_ceiXnIe_ofBzWlC_pQQ08c/pub"));
        } catch (Exception ignored) { }
      }
    });
    helpLabel.setIcon(new ImageIcon(MafiaView.class.getResource("/javax/swing/plaf/metal/icons/ocean/question.png")));

    contentPanel.add(helpLabel, "cell 0 0");
    urlField.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent arg0) {
        try {
          if (!canSpecifyThread) {
            Desktop d = Desktop.getDesktop();
            d.browse(new URI(urlField.getText()));
          }
        } catch (Exception ignored) { }
      }
    });
    urlField.setFont(new Font("Palatino Linotype", Font.PLAIN, 12));
View Full Code Here

            String log="";
            String result="";
            f = new File(filename);
            if (f == null) return;
            Desktop desktop = null;
            // Before more Desktop API is used, first check
            // whether the API is supported by this particular
            // virtual machine (VM) on this particular host.
            try
            {
                if (Desktop.isDesktopSupported())
                {
                    desktop = Desktop.getDesktop();
                    desktop.open(f);
                }
            }
            catch (IOException e)
            {
                log += System.err.toString();
View Full Code Here

            String log="";
            String result="";
            f = new File(filename);
            if (f == null) return;
            Desktop desktop = null;
            // Before more Desktop API is used, first check
            // whether the API is supported by this particular
            // virtual machine (VM) on this particular host.
            try
            {
                if (Desktop.isDesktopSupported())
                {
                    desktop = Desktop.getDesktop();
                    desktop.open(f);
                }
            }
            catch (IOException e)
            {
                log += System.err.toString();
View Full Code Here

        try {
          String url = get().getTO("data").getString("body");
          System.out.println(url);
         
          //TODO: write a better client for the shop.... will probably be a pain
          Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                try {
                    desktop.browse(new URI(url));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (InterruptedException | ExecutionException e) {
View Full Code Here

                } else if (count == 2
                    && feedListView.getItemAt(y) == index) {
                    Element itemElement = (Element)feedListView.getListData().get(index);

                    String link = XML.getText(itemElement, "link");
                    Desktop desktop = Desktop.getDesktop();

                    try {
                        desktop.browse(new URL(link).toURI());
                    } catch(MalformedURLException exception) {
                        throw new RuntimeException(exception);
                    } catch(URISyntaxException exception) {
                        throw new RuntimeException(exception);
                    } catch(IOException exception) {
View Full Code Here

            mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
            getContentPane().add(mainPanel);
        }

        private JPanel createButtonPanel() {
            final Desktop desktop = Desktop.getDesktop();
            JPanel buttonPanel = new JPanel(new GridLayout(1, 3, 10, 10));

            AbstractAction openBrowserAction = new AbstractAction("Show in browser") {
                @Override
                public void actionPerformed(ActionEvent event) {
                    try {
                        desktop.browse(reportFile.getAbsoluteFile().toURI());
                    } catch (IOException e) {
                        throw new IllegalStateException("Failed showing reportFile (" + reportFile
                                + ") in browser.", e);
                    }
                    finishDialog();
                }
            };
            openBrowserAction.setEnabled(desktop.isSupported(Desktop.Action.BROWSE));
            buttonPanel.add(new JButton(openBrowserAction));

            AbstractAction openFileAction = new AbstractAction("Show in files") {
                @Override
                public void actionPerformed(ActionEvent event) {
                    try {
                        desktop.open(reportFile.getParentFile());
                    } catch (IOException e) {
                        throw new IllegalStateException("Failed showing reportFile (" + reportFile
                                + ") in file explorer.", e);
                    }
                    finishDialog();
                }
            };
            openBrowserAction.setEnabled(desktop.isSupported(Desktop.Action.OPEN));
            buttonPanel.add(new JButton(openFileAction));

            AbstractAction closeAction = new AbstractAction("Ok") {
                @Override
                public void actionPerformed(ActionEvent e) {
View Full Code Here

   {
      if (url != null && url.isEmpty() == false)
      {
         if (Desktop.isDesktopSupported())
         {
            final Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.BROWSE))
            {
               try
               {
                  desktop.browse(new java.net.URI(url));
               }
               catch (Exception e)
               {
                  e.printStackTrace();
               }
View Full Code Here

TOP

Related Classes of java.awt.Desktop

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.