Update of JProgressBar

Discussion in 'Java' started by Cengiz, Aug 6, 2003.

  1. Cengiz

    Cengiz Guest

    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);
    }
    }
    };
    }
    }
    Cengiz, Aug 6, 2003
    #1
    1. Advertising

  2. Cengiz

    Cyril Mrazek Guest

    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, (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);
    > }
    > }
    > };
    > }
    >}
    Cyril Mrazek, Aug 6, 2003
    #2
    1. Advertising

  3. Cengiz

    Cengiz Guest

    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 <> wrote in message news:<>...
    > 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, (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);
    > > }
    > > }
    > > };
    > > }
    > >}
    Cengiz, Aug 7, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Inertia_sublimation
    Replies:
    5
    Views:
    2,116
    Inertia_sublimation
    Jan 3, 2004
  2. FET

    JProgressbar look n feel

    FET, Jul 22, 2004, in forum: Java
    Replies:
    3
    Views:
    1,497
  3. C.Steamer

    Problems with JProgressBar!!!

    C.Steamer, Sep 22, 2004, in forum: Java
    Replies:
    2
    Views:
    1,051
    ***C.Steamer***
    Sep 22, 2004
  4. Russell
    Replies:
    1
    Views:
    586
    Alex Hunsley
    Oct 17, 2004
  5. EdUarDo

    JProgressBar issue

    EdUarDo, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    897
    Andrew Thompson
    Jan 29, 2005
Loading...

Share This Page