Package java.awt

Examples of java.awt.Desktop


    }
   
    @Override
    public void actionPerformed(final ActionEvent e) {
      if (Desktop.isDesktopSupported()) {
        final Desktop desktop = Desktop.getDesktop();
        try {
          desktop.browse(new URI("http://www.google.com/search?q=" + searchText.get().replaceAll(" ", "%20")));
        } catch (final Exception ignore) {
          // ignore
        }
      }
    }
View Full Code Here


    }

    public static boolean browse(URI uri) throws IOException , UnavailableServiceException {
        // Try using the Desktop api first
        try {
            Desktop desktop = Desktop.getDesktop();
            desktop.browse(uri);

            return true;
        } catch (SecurityException e) {
//             Running in sandbox, try using WebStart service
            BasicService basicService =
View Full Code Here

  /**
   * Launch the given URL in the system browser
   * @param url the URL to launch
   */
  public static void openURL(String url) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Action.BROWSE)) {
      try {
        desktop.browse(new URI(url));
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
      }
    } else {
      fallbackURL(url);
View Full Code Here

        new HyperlinkLabel.OnClick() {

          @Override
          public void onClickDo(final MouseEvent me) {
            if (Desktop.isDesktopSupported()) {
              final Desktop desktop = Desktop.getDesktop();
              try {
                desktop.browse(new URI("http://www.dcaiti.com"));
              } catch (final Exception e) {
                e.printStackTrace();
              }
            }
          }

        });
    creditsLabel = new JLabel("Credits: Map Icons Collection");
    creditsLinkLabel = new HyperlinkLabel(
        "<html><a href=\"http://mapicons.nicolasmollet.com\">http://mapicons.nicolasmollet.com</a></html>\"",
        new HyperlinkLabel.OnClick() {

          @Override
          public void onClickDo(final MouseEvent me) {
            if (Desktop.isDesktopSupported()) {
              final Desktop desktop = Desktop.getDesktop();
              try {
                desktop.browse(new URI("http://mapicons.nicolasmollet.com"));
              } catch (final Exception e) {
                e.printStackTrace();
              }
            }
          }
View Full Code Here

    }// </editor-fold>//GEN-END:initComponents

    private void downloadlblMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_downloadlblMouseClicked
        // TODO add your handling code here:
        if (Desktop.isDesktopSupported()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.BROWSE)) {
                try {
                    desktop.browse(new URI(Way2SMSCore.downloadlink));
                } catch (Exception e) {
                    System.out.println(e);
                }

            }
View Full Code Here

    return null;
  }

  public static void openDesktopBrowser(String url) {
    Desktop desktop = Desktop.getDesktop();

    if (!desktop.isSupported(Desktop.Action.BROWSE)) {
      System.err.println("Desktop doesn't support the browse action.");
      return;
    }

    URI uri;
    try {
      uri = new URI(url);
      desktop.browse(uri);
    } catch (URISyntaxException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

   * @throws IOException
   * @throws IllegalArgumentException
   */
  boolean open() throws IOException, IllegalArgumentException {
    if ((path != null) && Desktop.isDesktopSupported()) {
      Desktop desktop = Desktop.getDesktop();
      if (desktop.isSupported(Desktop.Action.OPEN)) {
        desktop.open(new File(path));
        return true;
      }
    }
    return false;
  }
View Full Code Here

   * @throws IOException
   * @throws IllegalArgumentException
   */
  boolean open() throws IOException, IllegalArgumentException {
    if (path != null && Desktop.isDesktopSupported()) {
      Desktop desktop = Desktop.getDesktop();
      if (desktop.isSupported(Desktop.Action.OPEN)) {
        desktop.open(new File(path));
        return true;
      }
    }
    return false;
  }
View Full Code Here

        jButton2.setCursor(new Cursor(Cursor.HAND_CURSOR));
        jButton2.setText("Ajuda Online");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                    try {
                        desktop.browse(Cody.getInstancia().getLinkAjuda());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        });
       
        jButton4.setCursor(new Cursor(Cursor.HAND_CURSOR));
        jButton4.setText("Desenvolvedores");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                    try {
                        desktop.browse(Cody.getInstancia().getLinkDesenvolvedores());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
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);
            return;
        }

        try {
            desktop.open(file);
        } catch (Exception e) {
            if (e instanceof IOException) {
                copy(component, file);
            } else {
                showError(component, 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.