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

  • Home
  • SEARCH
  • 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 656905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:45:55+00:00 2026-05-13T22:45:55+00:00

I have an application that is works fine and the JFrame for it is

  • 0

I have an application that is works fine and the JFrame for it is launched in the constructor of a GameInitializer class which takes in some config parameters. I have tried to create a GUI in which allows the user to specify these config parameters and then click submit. When the user clicks submit a new GameInitializer object is created. The error I am getting is:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
    at java.awt.EventQueue.invokeAndWait(Unknown Source)
    at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
    at game.player.humanplayer.view.HumanView.update(HumanView.java:43)

once submit is called this code is executed:

values assigned to parames...   
    new GameInitializer(userName, player, Constants.BLIND_STRUCTURE_FILES.get(blindStructure), handState);

Then code in the GameInitializer constructor is:

public GameInitializer(String playerName, AbstractPlayer opponent, String blindStructureConfig, AbstractHandState handState){
        beginGame(playerName, opponent, blindStructureConfig, handState);
    }

    public static void beginGame(String playerName, AbstractPlayer opponent, String blindStructureConfig, AbstractHandState handState){
        AbstractDealer dealer;
        BlindStructure.initialize(blindStructureConfig);
        AbstractPlayer humanPlayer = new HumanPlayer(playerName, handState);

        AbstractPlayer[] players = new AbstractPlayer[2];
        players[0] = humanPlayer;
        players[1] = opponent;

        handState.setTableLayout(players);

        for(AbstractPlayer player : players){
            player.initialize();
        }

        dealer = new Dealer(players, handState);

        dealer.beginGame();
    }

It basically cascades down and eventually calls this piece of code in the HumanView class:

public void update(final Event event, final ReadableHandState handState, final AbstractPlayer player) {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {

                public void run() {
                    gamePanel.update(event, handState, player);
                    validate();
                }
            });
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        if(event.equals(Event.HAND_ENDING)){
            try {
                if(handState.wonByShowdown() || handState.isSplitPot()){
                    Thread.sleep(3500);
                }
                else{
                    Thread.sleep(1000);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

Do you have any idea why?

  • 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-13T22:45:56+00:00Added an answer on May 13, 2026 at 10:45 pm

    The point of invokeAndWait() is for another thread to wait for something to be done in the event dispatching thread (EDT). Since this code is already executing on the EDT, it’s sufficient to call it directly rather than creating a Runnable.

    So this code should not be surrounded by anything:

    gamePanel.update(event, handState, player); 
    validate(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a C# application that works fine on windows XP and windows vista
I have an application on appspot that works fine through regular browser, however when
I have an ASP.NET 3.0 application that works fine on one server. It uses
0 I have an ASP.NET 3.0 application that works fine on one server. It
I have a legacy Windows server service and (spawned) application that works fine in
I have an application that uses an HTTPWebRequest and works fine on the dev
I currently have a UINavigationController based application that works just fine. I'd like to
I have an application that uses SwitchUserFilter . The switching and exiting works fine
I have a web application that works in our stage/test environment fine but once
I have an application that works fine in Visual Studios 2008, and I am

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.