当前位置: 首页>>代码示例>>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;未经允许,请勿转载。