Java Reference
In-Depth Information
/**
* Run the background thread.
*/
public void run() {
Graphics g = null;
for (;;) {
if (this.connection == null) {
open();
}
if (g == null) {
g = getContentPane().getGraphics();
}
if (g != null) {
getStats();
displayStats(g);
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
return;
}
}
}
/**
* Draw a progress bar.
*
* @param g
* The graphics object.
* @param y
* The y position to draw the progress bar.
*/
private void displayProgressBar(Graphics g, int y) {
int width = getWidth();
int progressWidth = width - 20;
g.setColor(Color.GREEN);
g.fillRect(10, y, (int)
(progressWidth * this.donePercent), 16);
g.setColor(Color.BLACK);
g.drawRect(10, y, progressWidth, 16);
}
Search WWH ::




Custom Search