java - A swingworker does not work -
in application have 2 different swingworkers (they 2 different jobs). first 1 works perfectly, while latter not.
what can fix it?
class worker extends swingworker<boolean, string> { @override protected boolean doinbackground() throws exception { getstub().registration(name.gettext(), surname.gettext()); return true; } protected void done() { boolean status; try { status = get(); regstatus.settext("registration status: " + status); } catch (interruptedexception e) { } catch (executionexception e) { } } } class worker1 extends swingworker<boolean, string> { @override protected boolean doinbackground() throws exception { int = integer.parseint(id.gettext()); double r = double.parsedouble(range.gettext()); double la = double.parsedouble(lat.gettext()); coordinate lat = new degreecoordinate(la); double lo = double.parsedouble(lon.gettext()); coordinate lon = new degreecoordinate(lo); system.out.println("id: "+i+" lat: "+la+ " lon: "+lo+" type: "+type.gettext()+ " range: "+r); getstub().request(i, lat ,lon ,type.gettext(), r); return true; } protected void done() { boolean status; try { status = get(); reqstatus.settext("request status: " + status); } catch (interruptedexception e) { } catch (executionexception e) { } } }
and 2 jbuttons start worker
private jbutton register = new jbutton("register"); register.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { new worker().execute(); } }); private jbutton search = new jbutton("search now"); search.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { reqstatus.settext("i'm searching..."); new worker1().execute(); } });
the problem in large scope
looks you're using ninja-exception-logging (the invisible one):
} catch (interruptedexception e) { } catch (executionexception e) { }
do real logging there , see problem. @ least use system.out.println()
; better choice log4j.
} catch (interruptedexception e) { //a thread exception, quite unlikely happen system.out.println(e); } catch (executionexception e) { system.out.println(e); }
the particular mistake
with logging enabled, numberformatexception
, wrapped in executionexception
found.
Comments
Post a Comment