加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 使用Netbean的桌面应用程序的状态栏

发布时间:2020-12-15 08:34:14 所属栏目:Java 来源:网络整理
导读:我想知道在创建桌面应用程序工作时实际创建netbeans提供的状态栏的方法,但我真的不明白如何. 我包含下面的代码,这样每个人都可以理解我的意思以及在netbeans中找到它的位置. // status bar initialization - message timeout,idle icon and busy animation,e
我想知道在创建桌面应用程序工作时实际创建netbeans提供的状态栏的方法,但我真的不明白如何.

我包含下面的代码,这样每个人都可以理解我的意思以及在netbeans中找到它的位置.

// status bar initialization - message timeout,idle icon and busy animation,etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger(
            "StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout,new ActionListener()
    {

        @Override
        public void actionPerformed(ActionEvent e)
        {
            statusMessageLabel.setText("");
        }
    });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger(
            "StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++)
    {
        busyIcons[i] = resourceMap.getIcon(
                "StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate,new ActionListener()
    {

        @Override
        public void actionPerformed(ActionEvent e)
        {
            busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
            statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
        }
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(
            getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener()
    {

        @Override
        public void propertyChange(
                java.beans.PropertyChangeEvent evt)
        {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName))
            {
                if (!busyIconTimer.isRunning())
                {
                    statusAnimationLabel.setIcon(busyIcons[0]);
                    busyIconIndex = 0;
                    busyIconTimer.start();
                }
                progressBar.setVisible(true);
                progressBar.setIndeterminate(true);
            } else if ("done".equals(propertyName))
            {
                busyIconTimer.stop();
                statusAnimationLabel.setIcon(idleIcon);
                progressBar.setVisible(false);
                progressBar.setValue(0);
            } else if ("message".equals(propertyName))
            {
                String text = (String) (evt.getNewValue());
                statusMessageLabel.setText(
                        (text == null) ? "" : text);
                messageTimer.restart();
            } else if ("progress".equals(propertyName))
            {
                int value = (Integer) (evt.getNewValue());
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            }
        }
    });

我明白,这可能与TaskMonitor有关,但我无法理解.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读