當前位置: 首頁>>代碼示例>>Java>>正文


Java Action類代碼示例

本文整理匯總了Java中java.awt.Desktop.Action的典型用法代碼示例。如果您正苦於以下問題:Java Action類的具體用法?Java Action怎麽用?Java Action使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Action類屬於java.awt.Desktop包,在下文中一共展示了Action類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSupported

import java.awt.Desktop.Action; //導入依賴的package包/類
@Override
public boolean isSupported(Action action) {
    switch(action) {
        case OPEN:
        case EDIT:
        case PRINT:
        case MAIL:
        case BROWSE:
        case MOVE_TO_TRASH:
        case APP_SUDDEN_TERMINATION:
        case APP_EVENT_SYSTEM_SLEEP:
            return true;
        case APP_EVENT_USER_SESSION:
            return isEventUserSessionSupported;
        default:
            return false;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:WDesktopPeer.java

示例2: connectToServerUsingProtocol

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Connects to the given server (IP and Port) using an empty (no) password.
 * Other than
 * {@link GTAController#connectToServer(String)} and
 * {@link GTAController#connectToServer(String, String)}, this method uses the
 * <code>samp://</code> protocol to connect to make the samp launcher connect to
 * the server.
 *
 * @param ipAndPort
 *            the server to connect to
 * @return true if it was most likely successful
 */
private static boolean connectToServerUsingProtocol(final String ipAndPort) {
	if (!OSUtility.isWindows()) {
		return false;
	}

	try {
		Logging.info("Connecting using protocol.");
		final Desktop desktop = Desktop.getDesktop();

		if (desktop.isSupported(Action.BROWSE)) {
			desktop.browse(new URI("samp://" + ipAndPort));
			return true;
		}
	}
	catch (final IOException | URISyntaxException exception) {
		Logging.warn("Error connecting to server.", exception);
	}

	return false;
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:33,代碼來源:GTAController.java

示例3: display

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Display user guide section.
 *
 * @param section the section
 */
public void display(String section) {
    URL url = null;
    try {
        if (section == null) {
            url = new URL(USER_GUIDE_URL);
        } else {
            url = new URL(USER_GUIDE_URL + "#" + section);
        }
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    }

    if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
        Desktop desktop = Desktop.getDesktop();
        try {
            desktop.browse(url.toURI());
        } catch (IOException | URISyntaxException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:27,代碼來源:Help.java

示例4: display

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Display report issue section.
 */
public void display() {
    URL url = null;
    try {
        url = new URL(REPORT_ISSUE_URL);
    } catch (MalformedURLException e1) {
        ConsoleManager.getInstance().exception(this, e1);
    }

    if (url != null) {
        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
            Desktop desktop = Desktop.getDesktop();
            try {
                desktop.browse(url.toURI());
            } catch (IOException | URISyntaxException e) {
                ConsoleManager.getInstance().exception(this, e);
            }
        }
    }
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:23,代碼來源:ReportIssue.java

示例5: executeFile

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Executes the given file.
 * @param file The file to be executed
 * @return True on success; false otherwise
 */
public static boolean executeFile(final File file) {
	final boolean desktopSupported = Desktop.isDesktopSupported();
	
	if (desktopSupported && file.exists()) {
		final Desktop desktop = Desktop.getDesktop();
		final boolean canOpen = desktop.isSupported(Action.OPEN);
		
		if (canOpen) {
			try {
				desktop.open(file);
				
				return true;
			} catch (final Exception ex) {
				ex.printStackTrace();
			}
		}
	}
	
	return false;
}
 
開發者ID:Sogomn,項目名稱:spjgl,代碼行數:26,代碼來源:FileUtils.java

示例6: browse

import java.awt.Desktop.Action; //導入依賴的package包/類
public static void browse(String url) throws BrowseException {
    if(Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        if(desktop.isSupported(Action.BROWSE)) {
            try {
                desktop.browse(new URI(url));
            } catch (Exception e) {
                throw new BrowseException();
            }
        }
        else {
            throw new BrowseException();
        }
    }
    else {
        throw new BrowseException();
    }
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:19,代碼來源:I2PDesktop.java

示例7: openURL

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Open the given URL in the system web browser.
 *
 * @param uri
 *            the {@link URI} to be opened
 *
 * @return <code>true</code> if call to open was successfully made,
 *         <code>false</code> otherwise. A value of <code>true</code> DOES
 *         NOT guarantee that the {@link URI} was opened, but only that the
 *         call was successfully made.
 */
public static boolean openURL(URI uri) {
	if(!Desktop.isDesktopSupported()) {
		return false;
	}

	Desktop d = Desktop.getDesktop();
	if(!d.isSupported(Action.BROWSE)) {
		return false;
	}

	try {
		d.browse(uri);
		return true;
	} catch (IOException e) {
		return false;
	}
}
 
開發者ID:sangupta,項目名稱:jerry-core,代碼行數:29,代碼來源:DesktopUtils.java

示例8: createOpenParentFolderAction

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Utility method to create an action that opened a given file.
 * @param path path to the file
 * @return corresponding action
 */
public static SeerClickableLabelAction createOpenParentFolderAction(final String path) {
    return () -> {
        File file = new File(path);
        try {
            if (file.exists() && System.getProperty("os.name").startsWith("Windows"))
                Runtime.getRuntime().exec("Explorer /select," + file.getParentFile().getAbsolutePath() + "\\" + file.getName());
            else {
                Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                if (desktop != null && desktop.isSupported(Action.OPEN))
                    Desktop.getDesktop().open(file.getParentFile());
            }
        }
        catch (IOException | RuntimeException e) {
            // ignored
        }
    };
}
 
開發者ID:imsweb,項目名稱:naaccr-xml,代碼行數:23,代碼來源:SeerClickableLabel.java

示例9: openURL

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:17,代碼來源:BrowserLauncher.java

示例10: gotoHomepage

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
  * Launches browser with homepage.
  */
 public void gotoHomepage() {
   if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
     try {
Desktop.getDesktop().browse(new URI(HOMEPAGE));
     }
     catch (Exception e) {
System.err.println("Failed to launch browser with homepage!");
e.printStackTrace();
     }
   }
 }
 
開發者ID:fracpete,項目名稱:screencast4j,代碼行數:15,代碼來源:ScreencastPanel.java

示例11: showDownloadPage

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * Show download page.
 */
public void showDownloadPage() {
    if (client != null) {
        URL url = client.getDownloadURL();

        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) {
            Desktop desktop = Desktop.getDesktop();
            try {
                desktop.browse(url.toURI());
            } catch (IOException | URISyntaxException e) {
                e.printStackTrace();
            }
        }
    }
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:18,代碼來源:CheckUpdate.java

示例12: isSupported

import java.awt.Desktop.Action; //導入依賴的package包/類
public boolean isSupported(Action action)
{
  String check = null;

  switch(action)
  {
    case BROWSE:
      check = _BROWSE;
      break;

    case MAIL:
      check = _MAIL;
      break;

    case EDIT:
      check = _EDIT;
      break;

    case PRINT:
      check = _PRINT;
      break;

    case OPEN: default:
      check = _OPEN;
      break;
  }

  return this.supportCommand(check);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:30,代碼來源:ClasspathDesktopPeer.java

示例13: isSupported

import java.awt.Desktop.Action; //導入依賴的package包/類
public boolean isSupported(Action action)
{
  String check = null;
  
  switch(action)
  {
    case BROWSE:
      check = _BROWSE;
      break;
      
    case MAIL:
      check = _MAIL;
      break;
      
    case EDIT:
      check = _EDIT;
      break;
      
    case PRINT:
      check = _PRINT;
      break;
    
    case OPEN: default:
      check = _OPEN;
      break;
  }
  
  return this.supportCommand(check);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:30,代碼來源:ClasspathDesktopPeer.java

示例14: HyperlinkAction

import java.awt.Desktop.Action; //導入依賴的package包/類
/**
 * 
 * @param uri the target uri, maybe null.
 * @param desktopAction the type of desktop action this class should perform, must be
 *    BROWSE or MAIL
 * @throws HeadlessException if {@link
 * GraphicsEnvironment#isHeadless()} returns {@code true}
 * @throws UnsupportedOperationException if the current platform doesn't support
 *   Desktop
 * @throws IllegalArgumentException if unsupported action type 
 */
public HyperlinkAction(URI uri, Action desktopAction) {
    super();
    if (!Desktop.isDesktopSupported()) {
        throw new UnsupportedOperationException("Desktop API is not " +
                                                "supported on the current platform");
    }
    if (desktopAction != Desktop.Action.BROWSE && desktopAction != Desktop.Action.MAIL) {
       throw new IllegalArgumentException("Illegal action type: " + desktopAction + 
               ". Must be BROWSE or MAIL");
    }
    this.desktopAction = desktopAction;
    getURIVisitor();
    setTarget(uri);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:26,代碼來源:HyperlinkAction.java

示例15: detectFromOs

import java.awt.Desktop.Action; //導入依賴的package包/類
public static LaunchingStrategy detectFromOs() {
	if (Desktop.isDesktopSupported() &&
			Desktop.getDesktop().isSupported(Action.BROWSE)) {
		return DESKTOP_BROWSE;
	} else {
		String os = System.getProperty("os.name").toLowerCase();
		if (os.contains("nix") || os.contains("nux") ||
				os.contains("aix")) return XDG_OPEN_COMMAND;
		else if (os.contains("mac")) return OPEN_COMMAND;
		else return BROWSER_LAUNCHING_NOT_SUPPORTED;
	}
}
 
開發者ID:awvalenti,項目名稱:bauhinia,代碼行數:13,代碼來源:BrowserLauncher.java


注:本文中的java.awt.Desktop.Action類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。