私はSwingが初めてです。SwingWorker クラスを実装しましたが、どういうわけかリストが表示されません。以下のコードを参照して、「System.out.println」内の行が印刷されない理由を教えてください。
以下は SwingWorker コードです。execute メソッドのロジックもあります。コードをデバッグすると、「RoutingList rlist = new RoutingList();」になります。ライン。しかし、その行の後、「FutureTask.java」とそのメソッド「void innerRun()」に移動し、そこで例外「NoClassDefFound」がスローされ、残りのコードが無視されます。
private class RoutingDataLoader extends javax.swing.SwingWorker<List<RoutingBean>, RoutingBean> {
private final RoutingTableModel routingTableModel;
private final List<RoutingBean> routings = new ArrayList<RoutingBean>();
private JLabel credits;
private RoutingDataLoader(RoutingTableModel tableModel) {
this.routingTableModel = tableModel;
}
@Override
public List<RoutingBean> doInBackground() {
RoutingList rlist = new RoutingList();
List<RoutingBean> list = rlist.getRoutingList();
System.out.println("Routing Size: " + list.size());
for (int i = 0; i < list.size(); i++) {
RoutingBean bean = list.get(i);
routings.add(bean);
if (routings.size() % 3 == 0) {
try { // slow it down so we can see progress :-)
Thread.sleep(1);
} catch (Exception ex) {
}
}
publish(bean);
setProgress(100 * (i+1) / list.size());
}
return routings;
}
//@Override
protected void process(List<RoutingBean> moreRoutings) {
if (credits == null) {
showCredits();
}
routingTableModel.add(moreRoutings);
}
// For older Java 6 on OS X
protected void process(RoutingBean... moreRoutings) {
for (RoutingBean routing : moreRoutings) {
routingTableModel.add(routing);
}
}
private void showCredits() {
credits = new JLabel(getString("DataSheetTable.credits",
"<html><p align=\"center\">Academy Award data<br>courtesy of Howard Katz</p></html>"));
credits.setFont(UIManager.getFont("Table.font").deriveFont(24f));
credits.setHorizontalAlignment(JLabel.CENTER);
credits.setBorder(new CompoundBorder(new TitledBorder(""),
new EmptyBorder(20, 20, 20, 20)));
dataPanel.showMessageLayer(credits, .75f);
}
@Override
protected void done() {
setProgress(100);
dataPanel.hideMessageLayer();
}
}
ここに RoutingList クラスがあります
public class RoutingList {
private List<RoutingBean> routingList;
public RoutingList(List<RoutingBean> routingList) {
this.routingList = routingList;
}
public RoutingList() {
if (this.routingList == null) {
this.routingList = new ArrayList<RoutingBean>(0);
}
retrieveList();
}
public List<RoutingBean> getRoutingList() {
return routingList;
}
public void setRoutingList(List<RoutingBean> routingList) {
this.routingList = routingList;
}
public void retrieveList() {
DecimalFormat myFormatter = new DecimalFormat("0000");
for (int i = 0; i < 100; i++) {
RoutingBean bean = new RoutingBean();
String number = myFormatter.format(i);
OrganizationBean homeOrg = new OrganizationBean();
homeOrg.setOrganization_identifier(GetUniqueIdentifier.getUniqueIdentifier());
homeOrg.setOrganization_name("HomeOrg_" + number);
bean.setHome_organization_bean(homeOrg);
DivisionBean homeDiv = new DivisionBean();
homeDiv.setDivision_identifier(GetUniqueIdentifier.getUniqueIdentifier());
homeDiv.setDivision_name("HomeDiv_" + number);
bean.setHome_division_bean(homeDiv);
OrganizationBean partOrg = new OrganizationBean();
partOrg.setOrganization_identifier(GetUniqueIdentifier.getUniqueIdentifier());
partOrg.setOrganization_name("PartOrg_" + number);
bean.setPartner_organization_bean(partOrg);
DivisionBean partDiv = new DivisionBean();
partDiv.setDivision_identifier(GetUniqueIdentifier.getUniqueIdentifier());
partDiv.setDivision_name("PartDiv_" + number);
bean.setPartner_division_bean(partDiv);
TransactionSetBean transBean = new TransactionSetBean();
transBean.setTransactionSet_identifier(GetUniqueIdentifier.getUniqueIdentifier());
transBean.setTransactionSet_name("TransSet_" + number);
bean.setTransactionSet_bean(transBean);
DocumentStandardBean docStdBean = new DocumentStandardBean();
docStdBean.setDocumentStandard_identifier(GetUniqueIdentifier.getUniqueIdentifier());
docStdBean.setDocumentStandard_name("DocStd_" + number);
bean.setDocumentStandard_bean(docStdBean);
bean.setMap_name("MAP_" + number);
bean.setCommunication_identifier("Communication_" + number);
bean.setActive_flag("Active");
bean.setMode("Deferred");
this.routingList.add(bean);
}
}
}