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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:36:23+00:00 2026-05-25T15:36:23+00:00

I am using the latest Eclipse, and GWT Designer, to make a swing application

  • 0

I am using the latest Eclipse, and GWT Designer, to make a swing application in Java.
The main function in my application window (which is a javax.swing.JFrame) in the auto generated by the tools looks like this:

    /* launch the application */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                AppWindow window = new AppWindow();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

This seems like a lot of noise around what could have been just this:

public static void main(String[] args) {
            try {
                AppWindow window = new AppWindow();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }


}

I have read that the EventQueue.InvokeLater technique is required in some situations, and another question asks where to use it here.

My question is simpler; Why do this automatically in the code generator here? Why should main return quickly and let the application window get created later by the event queue? Wouldn’t blocking be exactly the point? Why is the JFrame auto-generated designer doing this EventQueue stuff? I have tried to see some difference in the start up and showing of forms whether this code is done the simpler way or the harder way, and I can only conclude provisionally that this has some benefits that are not visible in tiny demo apps made by beginners like me, and that perhaps in real-world large complex Jframe based classes, there is some benefit to this delaying/queuing strategy?

  • 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-25T15:36:24+00:00Added an answer on May 25, 2026 at 3:36 pm

    Depending on your application and how it’s being used, it’s possible that there could be something that is drawing on the screen (and thus using the EventQueue) before or during the call to your main method. Calls that modify any UI components should be made on the Event Dispatch Thread, and this includes setting the application visible.

    So just to be safe, it’s a good practice to start your application on the EDT.

    Why do this automatically in the code generator here?

    It won’t hurt, it’s easy to generate, and it’s considered good practice.

    Why should main return quickly and let the application window get created later by the event queue?

    It’s possible that the main method is being called from some other application that is using the EDT and may have already drawn something on screen. If you draw your application directly in main, it’s possible that your application may be altering some component that is in the process of being handled by something on the EDT, and potentially already drawn on the screen.

    So just to be safe in case this situation ever happens, you should leave it up to the EDT to draw your application so it can do it when it won’t interfere with anything else.

    Wouldn’t blocking be exactly the point?

    Unless something else is calling main other than the JVM process that your user started by double-clicking the desktop icon, it’s not going to make a difference when main returns as long as there is something on the screen.

    I can only conclude provisionally that this has some benefits that are not visible in tiny demo apps made by beginners like me

    You’re right – most of the time it’s probably not gonna make a difference, but I presume they included it because it was easy to generate & implement, it can’t hurt, and it would exemplify good practice.

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

Sidebar

Related Questions

I am using the latest Eclipse for Java EE & the latest JBoss Tools
I'm using Eclipse 3.6 with latest Sun Java 6 on Linux (64 bit) with
I try to deploy a GWT application, to Google App Engine using NetBeans. I
I'm using the latest version of Eclipse Galileo and I have to access the
I am using JUnit 4, Maven 2 and latest Eclipse. Problem is simple: I
I'm using Eclipse 3.5.2 on win7 with latest sdk update. Every time i create
Using latest php in order to create a function that adds a row to
I develop an Android application using Eclipse and the Android emulator. Sometimes I don't
I'm using the latest nightly build, VS2008 prof trial and .NET 3.5 and I'm
Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks

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.