Question

Is it possible to change progress bar color using the paint listner?

I don't want just an inital foreground and a background color, but want it to work just like how a normal green color progress bar works on Windows but with my own foreground and background.

I tried the below code but it won't work

GC gc = event.gc;
Device device=Display.getDefault();
Color foreground = gc.getForeground();
Color background = gc.getBackground();
gc.setForeground(device.getSystemColor(SWT.COLOR_RED));
gc.setBackground(device.getSystemColor(SWT.COLOR_YELLOW));

Am stuck with this requirement and have been told that it's possible using the paint listener, wondering how !

Any help would be appreciated.

Was it helpful?

Solution

The color of progress bars are determined by the operating system.

Under most conditions in Windows environments, the progress bar will be green. Using the setState(int state) command will change the "state" of the progress bar, which under some systems will also change the color - in Windows 7, paused results in yellow and error results in red. These statuses have other meaningful connotations, however, and it could be confusing to a user to use them simply for the stylistic reasoning of color. In the general sense, you should consider the color unchangable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top