本文整理匯總了Java中javax.swing.SwingWorker.addPropertyChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java SwingWorker.addPropertyChangeListener方法的具體用法?Java SwingWorker.addPropertyChangeListener怎麽用?Java SwingWorker.addPropertyChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SwingWorker
的用法示例。
在下文中一共展示了SwingWorker.addPropertyChangeListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DreamHouse
import javax.swing.SwingWorker; //導入方法依賴的package包/類
/**
* Create the application.
*/
public DreamHouse() {
SwingWorker worker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
c = new Controller();
return null;
}
};
final JDialog dialog = new JDialog();
worker.addPropertyChangeListener(new SwingerWorkerCompletionWaiter(dialog));
final JOptionPane oPane = new JOptionPane("I am learning. Please wait.", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
dialog.setTitle("Hello Dave");
dialog.setModal(true);
dialog.setContentPane(oPane);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.pack();
dialog.setLocationRelativeTo(null);
worker.execute();
dialog.setVisible(true);
initialize();
}
示例2: PredictHousePrice
import javax.swing.SwingWorker; //導入方法依賴的package包/類
/**
* Create the application.
*/
public PredictHousePrice() {
SwingWorker worker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
c = new Controller();
return null;
}
};
final JDialog dialog = new JDialog();
worker.addPropertyChangeListener(new SwingerWorkerCompletionWaiter(dialog));
final JOptionPane oPane = new JOptionPane("I am learning. Please wait.", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
dialog.setTitle("Hello Dave");
dialog.setModal(true);
dialog.setContentPane(oPane);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.pack();
dialog.setLocationRelativeTo(null);
worker.execute();
dialog.setVisible(true);
initialize();
}
示例3: createAction
import javax.swing.SwingWorker; //導入方法依賴的package包/類
public void createAction() {
zepui.processing.setText("Starting Conversion...");
zepui.processing.setForeground(Color.BLACK);
SwingWorker<Integer, Object> w = new SwingWorker<Integer, Object>() {
@Override
protected Integer doInBackground() throws Exception {
return convertAndSaveImages();
}
};
w.execute();
w.addPropertyChangeListener(evt -> {
if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
try {
int result = w.get();
switch (result) {
case 1 :
zepui.setSuccessText("All done! :-)");
break;
case -1 :
zepui.setErrorText("Error: Couldn't create outputfolder :-(");
break;
case -2 :
zepui.setErrorText("Error: Couldn't create outputfolder :-(");
break;
case -3 :
zepui.setErrorText("Error: Select an image first");
break;
}
} catch (InterruptedException | ExecutionException e) {
zepui.setErrorText("Error: Some unexpected shit happened :-(");
e.printStackTrace();
}
}
});
}
示例4: register
import javax.swing.SwingWorker; //導入方法依賴的package包/類
public void register(SwingWorker<?, ?> worker, String name) {
worker.addPropertyChangeListener(new Starter(this, name));
}