How to make a windows 7 loading bar on the taskbar

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

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.

  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.

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!