i'm trying set progressbar class failed. progressbar class upload
.
jprogressbar progressbar = new jprogressbar(); progressbar.setbounds(91, 134, 284, 17); frame.getcontentpane().add(progressbar);
i have class called read
. in class have loop needs read file, want set progress iterator i
class. know have set minimum , maxium this:
progressbar.setminimum(0); progressbar.setmaximum(numrows);
and value:
progressbar.setvalue(newvalue);
how can set value progressbar keeps updating value of i
?
first of all, reader class must have reference component (jprogressbar) in question. understand solved.
after that, reading file recommend use class extending javax.swing.swingworker
. pattern allows work in background (may heavy operations reading big files) without affecting awt thread, gui won't affected. so, reader should extend javax.swing.swingworker
.
as brief resume, provides method called doinbackground
should implement 'heavy' operation , method called process
received data chunks , add own calculations progress.
the process
method executed in awt, can update ui component @ method (so point update progress bar)
please, refer link more information.
Comments
Post a Comment