<code>
public
class
TestFrame
extends
JFrame {
public
TestFrame() {
this.setTitle(
"测试窗体"
);
initGUI();
}
private
void initGUI() {
SwingWorker worker =
new
SwingWorker<java.util.List<ConditionTerm>, Void>() {
@Override
protected
java.util.List<ConditionTerm> doInBackground() throws Exception {
condition.setTypeFlag(ConditionTermType.NORMAL);
ConditionTermDao dao =
new
ConditionTermDao();
return
dao.find();
}
@Override
protected
void done() {
FlowLayout layout =
new
FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
setLayout(layout);
try
{
JOptionPane.showMessageDialog(
new
JPanel(),
"1"
);
java.util.List<ConditionTerm> conditionTerms = get();
JOptionPane.showMessageDialog(
new
JPanel(), conditionTerms.size());
}
catch
(InterruptedException e) {
e.printStackTrace();
}
catch
(ExecutionException e) {
e.printStackTrace();
}
validate();
repaint();
}
};
worker.execute();
}
public
static
void main(String[] args) {
SwingUtilities.invokeLater(() -> {
TestFrame t =
new
TestFrame();
t.setVisible(true);
});
}
}
</code>