I want to create a windows 7 loading bar on the taskbar. something like this:
I already have a jframe frame where a game loads in it. I want to make the loadingbar show the progress of downloading the cache of the game. The jframe and the downloading are handled in two seperate classes.
When I looked on the web, I found 2 solutions.
SWT: where you can create the loadingbar, but I think you can't combine that with a jframe.
bridj: which is possible to add to jframe, but I don't have any idea how to do this with an existing jframe and the progress and the jframe handled in two different classes.
There is not a direct solution to what you ask since the progress task bar is OS unique, but trashgod actually got this answered at his post here .
You could create an icon which is affected by your progress & update it, so the taskbar will show what you ask for.
I was inspired, so had to indicate it in case OP didn't catch this. Nice job!
private static class ProgressIcon implements Icon {
private static final int H = 16;
private static final int W = 3 * H;
private Color color;
private int w;
public ProgressIcon(Color color) {
this.color = color;
}
public void update(int i) {
w = i % W;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(color);
g.fillRect(x, y, w, H);
}
public int getIconWidth() {
return W;
}
public int getIconHeight() {
return H;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.