本文整理汇总了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();
}