本文整理匯總了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();
}
示例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);
}
}
示例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();
}