I am new to Swing. I have implemented SwingWorker class but somehow its not displaying the list. Please see below code let me know why its not printing line inside "System.out.println"
Below is the SwingWorker code. I also have the logic for the execute method. When I debug my code its going into "RoutingList rlist = new RoutingList();" line. But After that line it take me to "FutureTask.java" and its method "void innerRun()" where it throws some exception "NoClassDefFound" and it ignores rest of my code.
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();
}
}
Here is the RoutingList class
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);
}
}
}