Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Display a progress bar in handheld applications

by Retired ‎02-16-2010 12:48 PM - edited ‎09-16-2010 02:33 PM (3,242 Views)



This article applies to the following:

  • BlackBerry® Java Development Environment (JDE)
  • BlackBerry smartphones



If a BlackBerry smartphone application must process information before displaying it for the BlackBerry smartphone user, displaying a progress bar for the application is especially important. While processing the information, the application must inform the BlackBerry smartphone user that it is still responsive and is preparing the requested data for display on the screen.


A GaugeField object can be used to display a progress bar while the application processes information.


The following code sample creates three different progress bars:



MainScreen mainScreen = new MainScreen(Field.USE_ALL_HEIGHT|Field.FIELD_LEFT);
GaugeField gaugeField = new GaugeField ("PROGRESS ", 0, 30, 15, Field.FOCUSABLE);
mainScreen.add (gaugeField);
GaugeField gaugeField2 = new GaugeField ("PERCENT ", 0, 30, 15, GaugeField.PERCENT);
mainScreen.add (gaugeField2);
GaugeField gaugeField3 = new GaugeField ("NO_TEXT ", 0, 30, 15, GaugeField.NO_TEXT);
mainScreen.add (gaugeField3);
pushScreen (mainScreen);



In the code sample above, the first GaugeField is the default progress bar. It is set as editable so the user can change the progress setting. The second progress bar shows the progress in terms of percentages. The last progress bar does not display any text in the progress bar and displays a blank gauge. All three progress bars have a minimum value of 0 and maximum value of 30. They are initialized to display progress to the halfway point.


Additional Information


The following is an image of the three progress bars from the code sample above:



Users Online
Currently online: 45 members 3,789 guests
Please welcome our newest community members: