This section illustrates you how to create a Progress Bar.
SWT allows to create a Progress bar by providing the class ProgressBar of package org.eclipse.swt.widgets. With the use of this class, you can display the progress in the form of bar. The method setMinimum() sets the minimum value and the method setMaximum() sets the maximum value for the progress bar. The method setSelection() sets the selection.
The method getSystemColor() returns the defined standard color of class Shell. The method fontMetrics.getAverageCharWidth() returns the average character width in pixels, of the default font and the method fontMetrics.getHeight() returns the height of the default font in pixels. The method gc.getFontMetrics returns the font metrics to draw the string.
Following code draws the string on the bar
|e.gc.drawString(string, (point.x-width)/2 , (point.y-height)/2, true);|
Here is the code of ProgressBarExample.java
Output will be displayed as:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.