当前位置: 首页>>代码示例>>Java>>正文


Java SwingWorker.get方法代码示例

本文整理汇总了Java中javax.swing.SwingWorker.get方法的典型用法代码示例。如果您正苦于以下问题:Java SwingWorker.get方法的具体用法?Java SwingWorker.get怎么用?Java SwingWorker.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.SwingWorker的用法示例。


在下文中一共展示了SwingWorker.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import javax.swing.SwingWorker; //导入方法依赖的package包/类
public static boolean run(SwingWorker<?,?> worker, Frame parent) throws Exception {
	ProgressDialog dialog = new ProgressDialog(parent, worker);
	worker.execute();
	dialog.setVisible(true);
	try {
		worker.get();
	}
	catch (ExecutionException e) {
		if (e.getCause() instanceof CancellationException) {
			return false;
		} else if (e.getCause() instanceof Exception) {
			throw (Exception)e.getCause();
		} else {
			// ?!?
			throw new AssertionError(e);
		}
	}
	
	return !worker.isCancelled();
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:21,代码来源:ProgressDialog.java

示例2: authenticate

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
 * authenticates using existing credentials without triggering the auth
 * workflow does nothing if offline
 */
public void authenticate() {
	if (offline)
		return;

	SwingWorker<ConnectionStatus, Object> connectionWorker = AsyncWork.goUnderground(authFunction,
			authContinuation);
	Events.ui.post(RunState.AUTHENTICATION_STARTED);
	try {
		connectionWorker.execute();
		logging.Info("attempting to authenticate");
		String msgAuthFailed = "authentication failed: ";
		try {
			ConnectionStatus result = connectionWorker.get(clientSettings.authTimeout, TimeUnit.SECONDS);
			if (result.status == HttpStatus.SC_OK)
				logging.Info("authentication succeeded");
			else
				logging.Info(msgAuthFailed + result.message.or("unknown reason"));
		} catch (InterruptedException | ExecutionException | TimeoutException e) {
			connectionWorker.cancel(true);
			logging.Info(String.format("%s %s %s", msgAuthFailed, e.getClass().getSimpleName(), e.getMessage()));
		}
	} finally {
		Events.ui.post(RunState.AUTHENTICATION_FINISHED);
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:30,代码来源:ClientController.java

示例3: playVideoAppear

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
 * Start playing the video.
 * @param sw the worker that will return the first frame.
 */
void playVideoAppear(final SwingWorker<BufferedImage, Void> sw) {
	videoAppearPercent = 0;
	try {
		videoAppear = sw.get();
	} catch (InterruptedException | ExecutionException ex) {
		Exceptions.add(ex);
	}
	buttonSound(SoundType.ACKNOWLEDGE_2);
	videoAppearAnim.start();
}
 
开发者ID:akarnokd,项目名称:open-ig,代码行数:15,代码来源:BridgeScreen.java


注:本文中的javax.swing.SwingWorker.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。