2010-01-05 53 views
1

下面是我用来显示从0到100的计量进度条的代码,同时计算网站中的字数。当它完成对单词数量的计数时,即当它达到100时,我希望它显示一些文本。然而,使用下面的代码我得到的是打印的else语句,因为在调用量表检查方法时它仍在计数。我如何解决这个问题?ProgressBar字计数器问题

public void SetGauge(int value) { 
    this.gg_Progress.setValue(value); 
} 



public void GaugeCheck() { 
    if (this.gg_Progress.getValue() == 100) { 
     progress_Result.setText("The number of words from this website have been successfully counted"); 
    } 
    else { 
     progress_Result.setText("The number of words has not been successfully counted"); 
    } 
} 




if (command == Continue2) { 
    // write pre-action user code here 
    switchDisplayable(null, getReading()); 
    // write post-action user code here 
    DelimiterCheck(tfd_Delimiter.getString()); 
    this.Count(); 
    this.GaugeCheck(); 
} 

回答

0

我建议您在第一次初始化仪器时只拨打progress_Result.setText("The number of words has not been successfully counted");一次。然后从GaugeCheck中删除else子句。

+0

当我删除else语句,就像你说的..没有东西被打印到屏幕上.. – Jaron787 2010-01-05 21:02:36

+0

我需要该方法来启动,只有this.count();方法已完成..我不确定你是如何做到这一点的? – Jaron787 2010-01-05 21:04:28

+0

不知道你的代码是如何工作的,我建议你找到一个合适的位置,在那里你开始计算并在那里插入你的第一个progress_Result.setText()调用。 – mopoke 2010-01-05 21:11:17