Update of JProgressBar

C

Cengiz

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);
}
}
};
}
}
 
C

Cyril Mrazek

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
 
C

Cengiz

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top