5

I want to create a windows 7 loading bar on the taskbar. something like this: This is what I want

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.

  1. SWT: where you can create the loadingbar, but I think you can't combine that with a jframe.

  2. 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.

5

1 Answer 1

1

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;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.