Update of JProgressBar  
Author Message
cengizo





PostPosted: 2003-8-7 0:20:00 Top

java-programmer, Update of JProgressBar Hi,

in my program i use a JProgressBar. I know, that i have to use another
Thread for updating the progressbar.
But with the following code it isn't working. What's wrong?

public class Parser1CheckVisitor{
int iCount = 0;
JFrameJRespCheck m_JFrameJRespCheck;
ResponseFile m_ResponseFile;

public Object visit(ASTrecord node, Object data) {
if (data != null) {
m_JFrameJRespCheck.jProgressBarPanelStatus.setMinimum(0);
m_JFrameJRespCheck.jProgressBarPanelStatus.setMaximum(m_ResponseFile.
m_iCount);

makeProgressThread().start();

for (iCount = 0; iCount < m_ResponseFile.m_iCount; iCount++) {
m_ChipFile.readRecord(iCount + 1);

data = node.childrenAccept(this, data);
}
}
return "OK";
}

Thread makeProgressThread() {
return new Thread() {
public void run() {
while (iCount != m_ResponseFile.m_iCount) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {}

m_JFrameJRespCheck.jProgressBarPanelStatus.setValue iCount);
//System.out.println(iCount);
}
}
};
}
}
 
Cyril Mrazek





PostPosted: 2003-8-7 1:17:00 Top

java-programmer >> Update of JProgressBar It is not clear how the members m_JFrameJRespCheck and m_ResponseFile
are instantiated and initialized. Have you removed these lines from
your example ?

Cyril Mrazek



On 6 Aug 2003 09:19:56 -0700, email***@***.com (Cengiz) wrote:

>Hi,
>
>in my program i use a JProgressBar. I know, that i have to use another
>Thread for updating the progressbar.
>But with the following code it isn't working. What's wrong?
>
>public class Parser1CheckVisitor{
> int iCount = 0;
> JFrameJRespCheck m_JFrameJRespCheck;
> ResponseFile m_ResponseFile;
>
> public Object visit(ASTrecord node, Object data) {
> if (data != null) {
> m_JFrameJRespCheck.jProgressBarPanelStatus.setMinimum(0);
> m_JFrameJRespCheck.jProgressBarPanelStatus.setMaximum(m_ResponseFile.
> m_iCount);
>
> makeProgressThread().start();
>
> for (iCount = 0; iCount < m_ResponseFile.m_iCount; iCount++) {
> m_ChipFile.readRecord(iCount + 1);
>
> data = node.childrenAccept(this, data);
> }
> }
> return "OK";
> }
>
> Thread makeProgressThread() {
> return new Thread() {
> public void run() {
> while (iCount != m_ResponseFile.m_iCount) {
> try {
> Thread.sleep(100);
> } catch (InterruptedException e) {}
>
>m_JFrameJRespCheck.jProgressBarPanelStatus.setValue iCount);
> //System.out.println(iCount);
> }
> }
> };
> }
>}

 
cengizo





PostPosted: 2003-8-7 18:08:00 Top

java-programmer >> Update of JProgressBar OK, i have it.
Within the while loop in the thread i have to invoke
m_JFrameJRespCheck.jProgressBarPanelStatus.update(m_JFrameJRespCheck.jProgressBarPanelStatus.getGraphics());

That's all.

Cyril Mrazek <email***@***.com> wrote in message news:<email***@***.com>...
> It is not clear how the members m_JFrameJRespCheck and m_ResponseFile
> are instantiated and initialized. Have you removed these lines from
> your example ?
>
> Cyril Mrazek
>
>
>
> On 6 Aug 2003 09:19:56 -0700, email***@***.com (Cengiz) wrote:
>
> >Hi,
> >
> >in my program i use a JProgressBar. I know, that i have to use another
> >Thread for updating the progressbar.
> >But with the following code it isn't working. What's wrong?
> >
> >public class Parser1CheckVisitor{
> > int iCount = 0;
> > JFrameJRespCheck m_JFrameJRespCheck;
> > ResponseFile m_ResponseFile;
> >
> > public Object visit(ASTrecord node, Object data) {
> > if (data != null) {
> > m_JFrameJRespCheck.jProgressBarPanelStatus.setMinimum(0);
> > m_JFrameJRespCheck.jProgressBarPanelStatus.setMaximum(m_ResponseFile.
> > m_iCount);
> >
> > makeProgressThread().start();
> >
> > for (iCount = 0; iCount < m_ResponseFile.m_iCount; iCount++) {
> > m_ChipFile.readRecord(iCount + 1);
> >
> > data = node.childrenAccept(this, data);
> > }
> > }
> return "OK";
> > }
> >
> > Thread makeProgressThread() {
> > return new Thread() {
> > public void run() {
> > while (iCount != m_ResponseFile.m_iCount) {
> > try {
> > Thread.sleep(100);
> > } catch (InterruptedException e) {}
> >
> >m_JFrameJRespCheck.jProgressBarPanelStatus.setValue iCount);
> > //System.out.println(iCount);
> > }
> > }
> > };
> > }
> >}