Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:59:07+00:00 2026-05-22T12:59:07+00:00

I would like to know a way to actually make the status bar that

  • 0

I would like to know a way to actually make the status bar that is provided by netbeans when you create a desktop application work, but I don’t really understand how.

I am including the code below so everyone can understand what I mean and where to find it in 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);
            }
        }
    });

I understand that ir probably has to do with the TaskMonitor but I cannot get it. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:59:07+00:00Added an answer on May 22, 2026 at 12:59 pm

    This is one of those unreasonably complicated things to do in Java. But it is doable. The NetBeans code expects you to put your executable code in a Task, attached to the TaskMonitor, and then it will work. Here is the example which worked for me:

    @Action
    public void myTaskButtonAction() { // this action is called from a menu item or a button
        startMyTaskAction();
    }
    @Action
    public Task startMyTaskAction() { // this sets up the Task and TaskMonitor
        StartMyTask task = new StartMyTask(org.jdesktop.application.Application.getInstance());
    
        ApplicationContext C = getApplication().getContext();
        TaskMonitor M = C.getTaskMonitor();
        TaskService S = C.getTaskService();
        S.execute(task);
        M.setForegroundTask(task);
    
        return task;
    }
    
    private class StartMyTask extends Task<Void, Void> { // this is the Task
        StartMyTask(org.jdesktop.application.Application app) {
            super(app);
        }
    
        @Override
        protected Void doInBackground() {
            try {
                // specific code for your task
                // this code shows progress bar with status message for a few seconds
                setMessage("starting up");// status message
                for(int progress=0; progress<100; progress += (int)(Math.random()*10)) {
                    setProgress(progress); // progress bar (0-100)
                    setMessage("prog: "+progress); // status message
                    try {
                        Thread.sleep((long)500); // sleep 500ms
                    } catch (InterruptedException ignore) {
                    }
                }
                setMessage("done");// status message
            }
            catch(java.lang.Exception e) {
                //specific code for exceptions
            }
    
            return null;
        }
    
        protected void succeeded() {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know a way to create an XML file using MySQL
I would like to know a way to implement a scenario that I am
I would like to know a way (of course I want to know the
I would like to know a way can detect on how long the mouse
I am using KnockoutJS and I would like to know of a way where
I would like to know if there's a way in java to find out
I would like to know if there is a way to execute polygons queries
I would like to know if there is any way to find the actual
I would like to know if there is a way to keep the session
I would like to know what's the best way to organize my php project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.