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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:52:30+00:00 2026-06-12T03:52:30+00:00

This simple issue confuses me. You can display a JAVA GUI application by setting

  • 0

This simple issue confuses me. You can display a JAVA GUI application by setting the frames’ setVisible property true. But in almost all the examples I found on internet they use a separate thread to do the same thing.

They do something like this,

SwingUtilities.invokeLater(new Runnable() {

    @Override
    public void run() {
        new Frame().setvisible(true);  //just take the idea of this line
    }
});

I found no difference between the two methods. But there must be some special reason, that’s why everyone is doing this.

Can someone explain it..thanks!

  • 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-12T03:52:31+00:00Added an answer on June 12, 2026 at 3:52 am

    The main reason for launching your application in this way is that Swing components are not thread-safe so you need to guarantee which thread your GUI will start from: the one called the Event Dispatching Thread (EDT). Without doing this, you can’t be sure what thread it will start in, but as noted by several kind commentators, the main thread is guaranteed not to be the EDT.

    You should only create, access, or modify UI components from within the EDT. Doing otherwise will result in unexpected behavior (if you’re lucky) and/or dirty repaints.

    Some resources I suggest you become familiar with:

    • The Event Dispatch Thread
    • Painting in AWT and Swing

    You could also have a read of Why does my boilerplate Java desktop app JFrame use EventQueue.invokeLater in the main method?

    UPDATE

    This is the blog I’ve been trying to find 😛

    This basically explains why it’s important to sync your main with the EDT before getting started, it also describes some of the details about why.

    It also describes why many developers make this fundamental mistake when starting their applications (basically, we were told we could, but we never were really allowed to…bad us)

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

Sidebar

Related Questions

This should be a simple issue but I can't figure this out. I have
This seems like such a simple issue but I cannot find an elegant solution.
Simple issue but I'm at a loss to debug this further. I followed the
I can't get past this issue I am having. Here's a simple example: class
This is a very simple issue. I must just be doing something stupid: This
I found out the next issue in this simple code: let () = print_endline
Here's the simple test to reproduce the issue, this is the single class in
It's an important security issue and I'm sure this should be possible. A simple
This might be a simple answer, but I am having some issues writing this
PROBLEM SOLVED: I was overlooking a very simple issue, and that is that this

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.