本文整理汇总了Java中javax.swing.SwingWorker.StateValue类的典型用法代码示例。如果您正苦于以下问题:Java StateValue类的具体用法?Java StateValue怎么用?Java StateValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StateValue类属于javax.swing.SwingWorker包,在下文中一共展示了StateValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performAttackButtonActionPerformed
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
private void performAttackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_performAttackButtonActionPerformed
String attackName = (String)attackComboBox.getSelectedItem();
currentActionProgressBar.setIndeterminate(true);
performAttackButton.setEnabled(false);
currentActionLabel.setText("Performing " + attackName + " Attack...");
enableAllButtons(false);
showProgressBar(true);
AttackWorker attackWorker = new AttackWorker(attackName, serviceProvider, EvaluationResultStore.getEvaluationResultStore().getLatestEvaluationResult());
attackWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> {
if (evt1.getPropertyName().equals("state")) {
if ((StateValue) evt1.getNewValue() == DONE) {
currentActionProgressBar.setIndeterminate(false);
performAttackButton.setEnabled(true);
currentActionLabel.setText("");
enableAllButtons(true);
setTrainined(true);
showProgressBar(false);
}
}
});
attackWorker.execute();
}
示例2: propertyChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ("state".equals(evt.getPropertyName())) {
if (evt.getNewValue().equals(StateValue.STARTED)) {
handler.incWorkersCount();
eventHook.apply();
start();
} else if (evt.getNewValue().equals(StateValue.DONE)) {
handler.decWorkersCount();
stop();
eventHook.remove();
}
} else if ("progress".equals(evt.getPropertyName())) {
handler.progress((Integer) evt.getNewValue());
}
}
示例3: propertyChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ((evt.getNewValue() instanceof StateValue)
&& ((StateValue) evt.getNewValue()) == StateValue.DONE) {
executing = false;
setEnabled(true);
getCancelButton().setEnabled(false);
getProgressBar().setIndeterminate(false);
}
else if (evt.getPropertyName().equals(FindEEGExperimentsWorker.WORKER_LOG_APPENDED_PROPERTY)) {
logger.debug("Appending" + evt.getNewValue());
getLogTextField().append((String) evt.getNewValue());
}
else if (evt.getPropertyName().equals(FindEEGExperimentsWorker.NEW_EXPERIMENTS_RECEIVED)) {
List<ExperimentDescriptor> newExperiments = (List<ExperimentDescriptor>) evt.getNewValue();
chooseExperimentTableModel.addExperiments(newExperiments);
}
}
示例4: stateChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
public void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
switch (newState) {
case STARTED:
started(source);
break;
case PENDING:
pending(source);
break;
case DONE:
done(source);
break;
default:
break;
}
}
示例5: propertyChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
//Catch the property changes of the CreateRandomWorker
public void propertyChange(PropertyChangeEvent evt) {
switch(evt.getPropertyName()) {
case "state": {
SwingWorker.StateValue state = (StateValue) evt.getNewValue();
if(state == SwingWorker.StateValue.DONE) {
progressMonitor.close();
}
}
case "progress": {
int progress = (Integer)evt.getNewValue();
progressMonitor.setProgress(progress);
break;
}
}
}
示例6: actionPerformed
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae)
{
if(m_Worker.isDone() || m_Worker.getState() == StateValue.PENDING)
{
// Prepare the Query to be run
QueryConvention q = new QueryConvention();
if(!textTagName.getText().equals(""))
q.TagName = textTagName.getText();
// Clean result
while(m_TableModel.getRowCount()>0)
m_TableModel.removeRow(0);
// UI feedback
m_ButtonSearch.setText("Cancel");
m_ButtonSearch.setMnemonic('C');
m_Tab.setIconAt(m_Index, Icon.window_loading);
// Run the Worker
m_Worker = new SearchConvention(q);
m_Worker.execute();
} else {
m_Worker.cancel(true);
}
}
示例7: propertyChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
/**
* Invoked when task's progress property changes.
*/
public void propertyChange(PropertyChangeEvent evt)
{
String evtName = evt.getPropertyName();
if ("state" == evtName)
{
}
else if (evtName.startsWith(PROGRESS_PREFIX))
{
int progress = (Integer) evt.getNewValue();
m_ProgressBar.setValue(progress);
m_LabelActivity.setText(evtName.substring(PROGRESS_PREFIX.length()));
}
else if (evtName.startsWith("activity:"))
{
m_LabelActivity.setText(evtName.substring("activity:".length()));
}
else if (evtName.startsWith("cancel"))
{
m_ModalDialog.setVisible(false);
}
else if (evtName.startsWith("error"))
{
m_TextTaskOutput.setForeground(Color.red);
m_TextTaskOutput.append(evtName.substring("error".length()));
}
else
{
m_TextTaskOutput.append(evtName+"\n");
m_TextTaskOutput.setCaretPosition(m_TextTaskOutput.getDocument().getLength());
}
if (m_Task != null && m_Task.getState() == StateValue.DONE && !m_Task.isCancelled())
{
m_ModalDialog.setVisible(false);
}
}
示例8: actionPerformed
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
public void actionPerformed(ActionEvent evt)
{
if (evt.getActionCommand().equalsIgnoreCase("CANCEL"))
{
if (m_Task.getState() == StateValue.DONE) {
m_ModalDialog.setVisible(false);
} else {
m_Task.cancel(true);
}
}
}
示例9: setLoadState
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
/**
* Callback for worker's state notification: cleanup if done.
* @param state
*/
public void setLoadState(StateValue state) {
//<snip>Use SwingWorker to asynchronously load the data
// remove progressbar if done loading
if (state != StateValue.DONE) return;
statusBarLeft.remove(progressBar);
statusBarLeft.remove(actionStatus);
revalidate();
repaint();
// </snip>
}
示例10: trainButtonActionPerformed
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
private void trainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButtonActionPerformed
serviceProvider = new ServiceProvider(serviceProviderTextField.getText());
EvaluationResult evaluationResult = new EvaluationResult(new Date(), serviceProviderTextField.getText());
EvaluationResultStore evaluationResultStore = EvaluationResultStore.getEvaluationResultStore();
evaluationResultStore.addEvaluationResult(evaluationResult);
enableAllButtons(false);
showProgressBar(true);
TrainingWorker trainingWorker = new TrainingWorker(serviceProvider, currentActionProgressBar, evaluationResult);
trainingWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> {
if (evt1.getPropertyName().equals("state")) {
if ((StateValue) evt1.getNewValue() == DONE) {
boolean cancelled = currentWorker.isCancelled();
System.out.println("cancelled: " + cancelled);
if (cancelled) {
try {
((TrainingWorker)currentWorker).awaitActualCompletion();
} catch (InterruptedException ex) {
Logger.getLogger(EvaluationGui.class.getName()).log(Level.SEVERE, null, ex);
}
}
enableAllButtons(true);
setTrainined(!cancelled);
showProgressBar(false);
}
}
System.out.println(evt1.getPropertyName() + " from " + evt1.getOldValue() + " to " + evt1.getNewValue());
});
trainingWorker.execute();
currentWorker = trainingWorker;
}
示例11: addPropertyChangeListenersTest
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
private void addPropertyChangeListenersTest(SwingWorker worker) {
worker.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
String eventName = event.getPropertyName();
if(eventName == "state") {
switch ((StateValue)event.getNewValue()) {
case STARTED:
case PENDING:
enableComponents(jPanelConfiguration, false);
enableComponents(jPanelTesting, false);
enableComponents(jPanelRun, false);
jButtonTestLights.setText("Cancel");
jButtonTestLights.setEnabled(true);
break;
case DONE:
jButtonTestLights.setText("Test Lights On/Off");
enableComponents(jPanelConfiguration, true);
enableComponents(jPanelTesting, true);
enableComponents(jPanelRun, true);
worker_ = null;
break;
}
}
}
});
}
示例12: stateChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
public void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
logger.trace("Mudança de estado do worker {} de {} para {}", source, oldState, newState);
switch (newState) {
case STARTED:
showView();
break;
case DONE:
hideView();
break;
default:
break;
}
}
示例13: stateChange
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
@Override
default void stateChange(SwingWorker<?, ?> source, StateValue oldState, StateValue newState) {
AbstractWorker<?, ?> worker = (AbstractWorker<?, ?>) source;
if (newState == StateValue.DONE && worker.isDoneWithSuccess()) {
doneWithSuccess(worker);
} else if (newState == StateValue.DONE) {
doneWithError(worker, worker.getLastError());
}
}
示例14: joinSelectedServer
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
private void joinSelectedServer() {
LogUtil.getLogger().log(Level.INFO,
"Fetching details for server: {0}", selectedServer.name);
final String url = tServerURL.getText();
final String trimmedInput = url.replaceAll("[\\r\\n\\s]", "");
final ServerJoinInfo joinInfo = session.getDetailsFromUrl(trimmedInput);
if (joinInfo == null) {
ErrorScreen.show("Cannot connect to given server",
"Unrecognized server URL. Make sure that you are using the correct link.", null);
} else if (joinInfo.passNeeded) {
getServerDetailsTask = session.getServerDetailsAsync(trimmedInput);
getServerDetailsTask.addPropertyChangeListener(
new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if ("state".equals(evt.getPropertyName())) {
if (evt.getNewValue().equals(StateValue.DONE)) {
onServerDetailsDone();
}
}
}
});
progress.setVisible(true);
if (Prefs.getKeepOpen()) {
disableGui();
}
getServerDetailsTask.execute();
} else {
joinServer(joinInfo);
}
}
示例15: startTransform
import javax.swing.SwingWorker.StateValue; //导入依赖的package包/类
void startTransform(){
//Create and instance of the analysis class
guiInput = new Hough_Circle();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.addKeyEventDispatcher(new MyDispatcher());
//Add an action listener to the status to allow for GUI to be updated
//Code modified from: http://www.javacreed.com/swing-worker-example/
guiInput.addPropertyChangeListener((final PropertyChangeEvent event) -> {
switch (event.getPropertyName()) {
//If event has progress flag, update progress bar
case "progress":
barString = guiInput.getStatus();
if(isGUI){
guiProgressBar.setIndeterminate(false);
guiProgressBar.setValue((Integer) event.getNewValue());
guiProgressBar.setString(barString);
}
break;
//if event has state flag, it indicates thread completion status
case "state":
switch ((StateValue) event.getNewValue()) {
//If worker thread is done, then clear out progress indicators and set button to "OK"
case DONE:
IJ.showProgress(0);
if(isGUI){
guiProgressBar.setVisible(false);
guiOKButton.setText("OK");
}
analysisStarted = false;
IJ.showStatus("Analysis complete...");
break;
//If worker has just started, set progress to indetertminate, to let user know plugin is active
case STARTED:
if(isGUI){
guiProgressBar.setVisible(true);
guiProgressBar.setIndeterminate(true);
guiProgressBar.setString("Starting Transform...");
}
break;
case PENDING:
if(isGUI){
guiProgressBar.setVisible(true);
guiProgressBar.setIndeterminate(true);
}
break;
}
break;
}
});
//Start the background transform by sending the GUI variables to the transform
guiInput.setParameters(radiusMin, radiusMax, radiusInc, minCircles, maxCircles, thresholdRatio, resolution, ratio, searchBand,
searchRadius, reduce, local, houghSeries, showCircles, showID, showScores, results, isGUI);
//Start the analysis on a separate thread so the GUI stays free.
guiInput.execute();
}