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 8134925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:13:37+00:00 2026-06-06T10:13:37+00:00

I have a GUI app that is getting to be quite slow. I want

  • 0

I have a GUI app that is getting to be quite slow. I want to start introducing timing for various GUI tasks – however, many of our GUI actions trigger other actions which then “invoke later” to trigger other actions.

Eventually, it all settles down and there’s nothing more to do. At this time, I want to stop a timer and report how long that GUI “action” took.

I figured the way to do this is to implement a method called invokeOnceIdle(Runnable task). The method will execute the supplied task only once the AWTEventQueue is “empty”. i.e. the supplied “task” should be the last thing in the queue.

One way to do this would be is if there’s a way to specify a “lowest” priority to SwingUtilities.invokeLater – but this isn’t possible.

I next looked to see if I could “invokeLater” a Runnable which checks to see if the event queue is “empty” – but there’s no public way to see if the event queue is actually empty.

What’s the best way to do this?

  • 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-06-06T10:13:38+00:00Added an answer on June 6, 2026 at 10:13 am

    Using your own event queue, you can easily reach that goal. Here something that I cooked up and should get you going:

    private static class MyEventQueue extends EventQueue {
    
        private Deque<Runnable> onceIdle = new LinkedList<Runnable>();
    
        public MyEventQueue() {
            Toolkit.getDefaultToolkit().getSystemEventQueue().push(this);
        }
    
        public void runOnceIdle(Runnable toRun) {
            onceIdle.addLast(toRun);
        }
    
        @Override
        protected void dispatchEvent(AWTEvent event) {
            super.dispatchEvent(event);
            if (peekEvent() == null) {
                for (Runnable toRun : onceIdle) {
                    toRun.run();
                }
                onceIdle.clear();
            }
        }
    }
    

    All you have to do is push your “Once idle” runnables to the instance of the EventQueue using runOnceIdle()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We (my colleagues) have a messy 12 y.o. mature app that is GUI-based, and
I have a GUI that is going to do a lot of disparate tasks.
We have a command line application that could benefit from a GUI. We want
I have a python-tkinter gui app that I've been trying to find some way
I have an app that uses RavenDB. It has a WPF front-end GUI app.
I have a wxLua Gui app that has a Run button. Depending on selected
I'm writing a GUI app that I want to use Swing and SWT. The
I have a MFC GUI app that has multiple frames (sort of like Outlook'ish
I have a python GUI app that uses a long running function from a
I have a fat GUI that it getting fairly complex, and I would like

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.