Package java.awt

Examples of java.awt.Desktop


    private Desktop getDesktop() {
        if (Desktop.isDesktopSupported() == false)
            return null;

        Desktop d = Desktop.getDesktop();
        if (d != null && d.isSupported(Action.OPEN))
            return d;
        else
            return null;
    }
View Full Code Here


        // Add a button press listener to open the Yahoo! Finance web page when
        // the link is clicked
        yahooFinanceButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                Desktop desktop = Desktop.getDesktop();

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

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof LinkModel) {
                final LinkModel link = (LinkModel) e.getSource();
                try {
                    Desktop desktop = Desktop.getDesktop();
                    desktop.browse(link.getURL().toURI());
                    link.setVisited(true);
                } catch (Exception e1) {
                    // TODO: error handling
                }
            }
View Full Code Here

//            System.out.println();
        } catch (Exception e) {}
    }
   
    public static void openDocument(File document) throws IOException {
        Desktop dt = Desktop.getDesktop();
        dt.open(document);
    }
View Full Code Here

        } else if (ae.getSource().equals(mi_game_play)) {
            setGameBeingPlayed(true);
        } else if (ae.getSource().equals(mi_game_stop)) {
            setGameBeingPlayed(false);
        } else if (ae.getSource().equals(mi_help_source)) {
            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            try {
                desktop.browse(new URI("https://github.com/Burke9077/Conway-s-Game-of-Life"));
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Source is available on GitHub at:\nhttps://github.com/Burke9077/Conway-s-Game-of-Life", "Source", JOptionPane.INFORMATION_MESSAGE);
            }
        } else if (ae.getSource().equals(mi_help_about)) {
            JOptionPane.showMessageDialog(null, "Conway's game of life was a cellular animation devised by the mathematician John Conway.\nThis Java, swing based implementation was created by Matthew Burke.\n\nhttp://burke9077.com\nBurke9077@gmail.com\n@burke9077\n\nCreative Commons Attribution 4.0 International");
View Full Code Here

  private void addPrintMenuItem() {
    if (!Desktop.isDesktopSupported()) {
      return;
    }

    final Desktop desktop = Desktop.getDesktop();
    if (!desktop.isSupported(Desktop.Action.PRINT)) {
      return;
    }

    JButton btnPrint = new JButton(Translator.tr("Print this file"));
    btnPrint.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent ev) {
        try {
          desktop.print(logWindow.getFile());
        } catch (IOException e) {
          logger.warning(e.getMessage());
        }
      }
    });
View Full Code Here

            String href = null;
            if (tagA!=null){
              href = (String)tagA.getAttribute(HTML.Attribute.HREF);
            }
            if (href != null) {
            Desktop desktop = Desktop.getDesktop();
            try {
          desktop.browse(new URI(href));
        } catch (IOException e1) {
           s_log.error("mouseClicked: Unexpected exception "+e1.getMessage());
        } catch (URISyntaxException e1) {
           s_log.error("mouseClicked: Unexpected exception "+e1.getMessage());
        }
View Full Code Here

      } else {
        boolean opened = false;
        // Java 6 specific code of how to run the browser
        if (Desktop.isDesktopSupported()) {
          try {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.BROWSE)) {
              desktop.browse(new URI(url));
              opened = true;
            }
          } catch (Exception e) {
            // do nothing
            opened = false;
View Full Code Here

  private void mail(final Frame parent, final String content, final String title) {
    // Java 6 desktop API
    boolean sent = false;
    if (Desktop.isDesktopSupported()) {
      Desktop desktop = Desktop.getDesktop();
      try {
        URI uriMailTo = new URI("mailto", "?body=" + content + "&subject=" + title, null);
        desktop.mail(uriMailTo);
        sent = true;
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
View Full Code Here

        s.invoke(null);
        System.exit(0);
      } else if (cmd.startsWith("!")) {
        //javax.swing.JOptionPane.showMessageDialog(null, String.format("http://localhost:%s/%s", port, contextPath));
        ti.displayMessage("TJWS", getResource("label_opening") + cmd.substring(1), TrayIcon.MessageType.INFO);
        Desktop desktop = Desktop.getDesktop();
        // TODO obtain host name, like inetaddress
        desktop.browse(new URI(String.format("http://%s:%s/%s", "localhost", port, cmd.substring(1))));
      } //else
      //javax.swing.JOptionPane.showMessageDialog(null, "Command "+event.getActionCommand());
    } catch (URISyntaxException e) {
      //e.printStackTrace();
    } catch (IOException e) {
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.