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