我想在任务栏上创建一个
Windows 7加载栏.这样的事情:
我已经有一个游戏加载的jframe框架.
我想让loadingbar显示下载游戏缓存的进度. jframe和下载在两个单独的类中处理.
当我在网上看时,我找到了2个解决方案.
> SWT:您可以在哪里创建加载栏,但我认为您无法将其与jframe结合使用.
> bridj:可以添加到jframe,但我不知道如何使用现有的jframe执行此操作,并且在两个不同的类中处理进度和jframe.
解决方法
由于进度任务栏是操作系统唯一的,所以没有直接解决你问的问题,但是垃圾邮件实际上已经在
here的帖子中得到了回答.
您可以创建一个受进度和影响的图标.更新它,因此任务栏将显示您的要求.
我受到启发,所以不得不指出它,以防OP没有抓住这个.不错的工作!
您可以创建一个受进度和影响的图标.更新它,因此任务栏将显示您的要求.
我受到启发,所以不得不指出它,以防OP没有抓住这个.不错的工作!
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; } }