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


Java SwingWorker.execute方法代码示例

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


在下文中一共展示了SwingWorker.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: updateTimestampMasterStatus

import javax.swing.SwingWorker; //导入方法依赖的package包/类
protected void updateTimestampMasterStatus() {
	final SwingWorker<Void, Void> masterUpdateWorker = new SwingWorker<Void, Void>() {
		@Override
		public Void doInBackground() {
			try {
				final int isMasterSPI = spiConfigReceive(CypressFX3.FPGA_SYSINFO, (short) 2);

				isMaster.set(isMasterSPI != 0);
			}
			catch (HardwareInterfaceException e) {
				// Ignore exceptions.
			}

			return (null);
		}
	};

	masterUpdateWorker.execute();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:CypressFX3.java

示例4: main

import javax.swing.SwingWorker; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventProcessor());

    SwingWorker<Void, CharSequence> swingWorker =
        new SwingWorker<Void,CharSequence>() {
            @Override
            protected Void doInBackground() {
                publish(new String[] {"hello"});
                publish(new StringBuilder("world"));
                return null;
            }
            @Override
            protected void done() {
                isDone.set(true);
            }
        };
    swingWorker.execute();

    while (! isDone.get()) {
        Thread.sleep(100);
    }
    if (throwable.get() instanceof ArrayStoreException) {
        throw new RuntimeException("Test failed");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:bug6432565.java

示例5: aniadirMangasMasivo

import javax.swing.SwingWorker; //导入方法依赖的package包/类
private void aniadirMangasMasivo() {
		// TODO Auto-generated method stub
		final SwingWorker worker = new SwingWorker() {
			@Override
			protected Object doInBackground() throws Exception {
				String rawEnlaces = textEnlaces.getText();
				String [] enlaces = rawEnlaces.split("\n");
				for (int i = 0; i < enlaces.length; i++) {
					ColaDescarga.addManga(enlaces[i]);
//					System.out.println("+ "+enlaces[i]);
				}
				return null;
			}
		};
		worker.execute();
		// dispose();
	}
 
开发者ID:angelh32,项目名称:JMangaCup,代码行数:18,代码来源:Principal.java

示例6: aniadirMangas

import javax.swing.SwingWorker; //导入方法依赖的package包/类
protected void aniadirMangas() {
//		// TODO Auto-generated method stub
		final SwingWorker worker = new SwingWorker(){
			@Override
			protected Object doInBackground() throws Exception {
				int inicio = Integer.parseInt(campoInicio.getText());
				int fin = Integer.parseInt(campoFin.getText());
				String url1=campoUrl1.getText();
				String url2=campoUrl2.getText();
				for (int i = inicio; i <= fin; i++) {
					System.out.println("Aniadiendo: "+url1+i+url2);
					ColaDescarga.addManga(url1+i+url2);
				}
				return null;
			}	
		};
		worker.execute();
		dispose();
	}
 
开发者ID:angelh32,项目名称:JMangaCup,代码行数:20,代码来源:Masivo.java

示例7: onExportButtonPressed

import javax.swing.SwingWorker; //导入方法依赖的package包/类
@Override
public void onExportButtonPressed() {
    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
            Exporter.writeCurrentClass(silverGhost.getCurrentClassName(),
                    silverGhost.getCurrentClassContent());
            Exporter.writeArchive(silverGhost.getBinaryArchive(),
                    silverGhost.getAllClassNames());
            return null;
        }

        protected void done() {
        }
    };

    worker.execute();
}
 
开发者ID:google,项目名称:android-classyshark,代码行数:19,代码来源:ClassySharkPanel.java

示例8: start

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
     * Callback method for demo loader. 
     */
    public void start() {
        if (oscarModel.getRowCount() != 0) return;
        //<snip>Use SwingWorker to asynchronously load the data
        // create SwingWorker which will load the data on a separate thread
        SwingWorker<?, ?> loader = new OscarDataLoader(
                XTableDemo.class.getResource("resources/oscars.xml"), oscarModel);
        
        // display progress bar while data loads
        progressBar = new JProgressBar();
        statusBarLeft.add(progressBar);
        // bind the worker's progress notification to the progressBar
        // and the worker's state notification to this
        BindingGroup group = new BindingGroup();
        group.addBinding(Bindings.createAutoBinding(READ, 
                loader, BeanProperty.create("progress"),
                progressBar, BeanProperty.create("value")));
        group.addBinding(Bindings.createAutoBinding(READ, 
                loader, BeanProperty.create("state"),
                this, BeanProperty.create("loadState")));
        group.bind();
        loader.execute();
//        </snip>
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:XTableDemo.java

示例9: requestResume

import javax.swing.SwingWorker; //导入方法依赖的package包/类
private void requestResume() {
	logger.entry();
	SwingWorker<String, Object> worker = new SwingWorker<String, Object>() {

		@Override
		protected String doInBackground() throws Exception {
			if (!requestRunning) {
				requestRunning = true;
				pluginModel.resume();
			}
			return "done";
		}
	};
	setBussyMouse(true);
	worker.execute();
	logger.exit();
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:18,代码来源:PluginView.java

示例10: requestPause

import javax.swing.SwingWorker; //导入方法依赖的package包/类
private void requestPause() {
	logger.entry();
	SwingWorker<String, Object> worker = new SwingWorker<String, Object>() {

		@Override
		protected String doInBackground() throws Exception {
			if (!requestRunning) {
				requestRunning = true;
				pluginModel.pause();
			}
			return "done";
		}
	};
	setBussyMouse(true);
	worker.execute();
	logger.exit();
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:18,代码来源:PluginView.java

示例11: requestAccessToken

import javax.swing.SwingWorker; //导入方法依赖的package包/类
private void requestAccessToken() {
    if (loginModel.isServerSelected()) {
        SwingWorker<String, Object> worker = new SwingWorker<String, Object>() {

            @Override
            protected String doInBackground() throws Exception {
                if (!requestRunning) {
                    requestRunning = true;
                    boolean success = (loginModel.getAccessToken() == ResponseCode.SUCCESS);
                    if (!success) {
                        errorLabel.setText(getLocalized(APP_NOT_AUTHORIZED_IN_STUDIP_LABEL));
                    } else {
                        errorLabel.setText("");
                        model.getPluginModel().activateNewPlugin(loginModel.getPluginInformation(),
                                loginModel.getOAuthConnector());
                    }
                }
                return "done";
            }
        };
        errorLabel.setText("");
        setBussyMouse(true);
        worker.execute();
    }
}
 
开发者ID:CollapsedDom,项目名称:Stud.IP-Client,代码行数:26,代码来源:LoginWindow.java

示例12: actionPerformed

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
 * Invoked when an action occurs.
 */
@Override
public void actionPerformed(final ActionEvent e) {
    Sampler c = Sampler.createManualSampler("Self Sampler");  // NOI18N
    if (c != null) {
        if (RUNNING.compareAndSet(null, c)) {
            putValue(Action.NAME, ACTION_NAME_STOP);
            putValue(Action.SHORT_DESCRIPTION, ACTION_NAME_STOP);
            putValue ("iconBase", "org/netbeans/core/ui/sampler/selfSamplerRunning.png"); // NOI18N
            c.start();
        } else if ((c = RUNNING.getAndSet(null)) != null) {
            final Sampler controller = c;

            setEnabled(false);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    controller.stop();
                    return null;
                }

                @Override
                protected void done() {
                    putValue(Action.NAME, ACTION_NAME_START);
                    putValue(Action.SHORT_DESCRIPTION, ACTION_NAME_START);
                    putValue ("iconBase", "org/netbeans/core/ui/sampler/selfSampler.png"); // NOI18N
                    SelfSamplerAction.this.setEnabled(true);
                }
            };
            worker.execute();
        }
    } else {
        NotifyDescriptor d = new NotifyDescriptor.Message(NOT_SUPPORTED, NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:SelfSamplerAction.java

示例13: calculateStatistics

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
 * Calculates the statistics of the given {@link ExampleSet} in a {@link SwingWorker}. Once the
 * statistics are calculated, will update the stats on all {@link AttributeStatisticsPanel}s.
 *
 * @param exampleSet
 */
private void calculateStatistics(final ExampleSet exampleSet) {
	final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

		@Override
		protected Void doInBackground() throws Exception {
			exampleSet.recalculateAllAttributeStatistics();
			waitAtBarrier();

			return null;
		}
	};
	worker.execute();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:MetaDataStatisticsController.java

示例14: checkFirmwareLogic

import javax.swing.SwingWorker; //导入方法依赖的package包/类
/**
 * Check the firmware and logic versions against required ones and display an error if not met.
 */
protected void checkFirmwareLogic(final int requiredFirmwareVersion, final int requiredLogicRevision)
	throws HardwareInterfaceException {
	final StringBuilder updateStringBuilder = new StringBuilder();

	// Verify device firmware version and logic revision.
	final int usbFWVersion = getDID() & 0x00FF;
	if (usbFWVersion < requiredFirmwareVersion) {
		updateStringBuilder
			.append(String.format("Device firmware version too old. You have version %d; but at least version %d is required.\n",
				usbFWVersion, requiredFirmwareVersion));
	}

	final int logicRevision = spiConfigReceive(CypressFX3.FPGA_SYSINFO, (short) 0);
	if (logicRevision < requiredLogicRevision) {
		updateStringBuilder
			.append(String.format("Device logic revision too old. You have revision %d; but at least revision %d is required.\n",
				logicRevision, requiredLogicRevision));
	}

	if (updateStringBuilder.length() > 0) {
		updateStringBuilder
			.append("Please updated by following the Flashy upgrade documentation at 'http://inilabs.com/support/reflashing/'.");

		final String updateString = updateStringBuilder.toString();

		final SwingWorker<Void, Void> strWorker = new SwingWorker<Void, Void>() {
			@Override
			public Void doInBackground() {
				JOptionPane.showMessageDialog(null, updateString);

				return (null);
			}
		};
		strWorker.execute();

		throw new HardwareInterfaceException(updateString);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:42,代码来源:CypressFX3.java

示例15: startContext

import javax.swing.SwingWorker; //导入方法依赖的package包/类
public void startContext() {
	// TODO Auto-generated method stub

	SwingWorker worker = new SwingWorker() {
		protected Object doInBackground() throws Exception {
			BootstrapManager.getBoostrap(getTomcat().getPort()).deployContexts();
			return null;
		}
	};
	worker.execute();

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:WebApp.java


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