BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 02-26-2007, 03:33 PM   #1 (permalink)
New Member
Join Date: Feb 2007
Model: 8830
Carrier: Sprint
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Progress Bar popup using GaugeField

Please Login to Remove!

I've seen a lot of posts on this, trying to find out how to do it myself. Thought I would post my solution, hoping that it helps somebody else out.

This code creates a popup screen that has a constantly updated progress bar, for when you would like the user to know that you are not just ignoring them, and that the application really is busy.

This could be modified easily to post a popup, similar to, except that it would not be removed from the screen until explicitly removed.

 * Defines ProgressBar object. Creates popup screen with title, and perpetually updating
 * progress gauge. Instantiate and run as thread to start progress update. Call
 * remove() method when finished to remove popup screen and shutdown thread.
package mrm.util;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.GaugeField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.DialogFieldManager;
import net.rim.device.api.ui.container.PopupScreen;

public class ProgressBar extends Thread {

	private int maximum, timeout;

	private boolean useful;

	private PopupScreen popup;

	private GaugeField gaugeField;

	 * Object constructor
	 * @param title
	 *           Text to display on popup area
	 * @param maximum
	 *           Range / width of the gauge field of progress bar
	 * @param timeout
	 *           Milliseconds to pause between updates to progress bar
	 * @see GaugeField
	 * @see Thread
	 * @see PopupScreen

	public ProgressBar(String title, int maximum, int timeout) {
		this.maximum = maximum;
		this.timeout = timeout;

		DialogFieldManager manager = new DialogFieldManager();

		popup = new PopupScreen(manager);
		gaugeField = new GaugeField(null, 1, maximum, 1, GaugeField.NO_TEXT);

		manager.addCustomField(new LabelField(title));

	 * run() method for starting thread

	public void run() {
		useful = true;

		UiApplication.getUiApplication().invokeLater(new Runnable() {
			public void run() {

		int iterations = 0;

		while (useful) {
			try {
			} catch (Exception e) {

			if (++iterations > maximum)
				iterations = 1;


		if (popup.isDisplayed()) {
			UiApplication.getUiApplication().invokeLater(new Runnable() {
				public void run() {

	 * Method to shutdown the thread and remove the popup screen

	public synchronized void remove() {
		useful = false;
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

20Pcs Ad620an Ad620anz Dip-8 Instrumentation Amplifier Analog Devices Ic New E
20Pcs Ad620an Ad620anz Dip-8 Instrumentation Amplifier Analog Devices Ic New E pictureAllen-Bradley 2098-DSD-HV100X-DN Ultra 3000i Servo Drive
Allen-Bradley 2098-DSD-HV100X-DN Ultra 3000i Servo Drive pictureAllen-Bradley 2098-IPD-005 Ultra5000 Drive
Allen-Bradley 2098-IPD-005 Ultra5000 Drive pictureThermo Finnigan MAT LCQ Mass RF Amplifier 96000-61090 Rev.F Board
Thermo Finnigan MAT LCQ Mass RF Amplifier 96000-61090  Rev.F Board picturePacific Scientific SC753A001-01 Unknown Condition
Pacific Scientific SC753A001-01 Unknown Condition picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.