當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。