如何在任务栏上制作Windows 7加载栏 [英] How to make a windows 7 loading bar on the taskbar

查看:41
本文介绍了如何在任务栏上制作Windows 7加载栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在任务栏上创建Windows 7加载栏.像这样的东西:

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

我已经有一个jframe框架,可以在其中加载游戏.我想让loadingbar显示下载游戏缓存的进度.jframe和下载在两个单独的类中处理.

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:您可以在其中创建加载栏,但我认为您无法将其与jframe结合使用.

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

bridj:可以添加到jframe中,但是我不知道如何使用现有的jframe以及如何在两个不同的类中处理进度和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.

推荐答案

由于进度任务栏是操作系统唯一的,因此无法直接解决您要问的问题,但是 trashgod 实际上在以下位置给出了答案他的帖子此处.
>您可以创建一个受进度和进度影响的图标.更新它,以便任务栏将显示您的要求.
我很受启发,所以必须指出这一点,以防OP未能抓住这一点.干得好!

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

这篇关于如何在任务栏上制作Windows 7加载栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆