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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:28:19+00:00 2026-05-29T11:28:19+00:00

I have written a program which uses CardLayout. I want it to show a

  • 0

I have written a program which uses CardLayout. I want it to show a JPanel and then, based on the user’s input, shows a new JPanel, pause for 3 seconds, and then show another JPanel which requires user input.

My JPanel requiring user input works fine, and the debugging I’ve done has shown me that when the program pauses for 3 seconds, the “filler” panels (see below) are being generated, but just not rendered properly.

class sylBetween extends JPanel{

    sylBetween(boolean response, String fileName){
        super();
        setSize(1365,725);
        JLabel cross = new JLabel("+");
        JLabel display;
        boolean feedback = myParticipant.getFeedbackTF();
        if(feedback){

            String v = syllogism.getSyllValidity(fileName);
            if(v.equals("V")&&response==true||v.equals("I")&&response==false){
                display=new JLabel("Correct");          
            }
            else{
                display=new JLabel("Incorrect");
            }

            add(display);
        }
        else{
            add(cross);
        }
    }
}

and I think the problem is in this bit of code, but I can’t figure out why:

    public void actionPerformed(ActionEvent e) {

        String name = s[currentTrial].getFN();

        boolean answerTF = false;
        if(e.getSource()==s[currentTrial].yes){
            answerTF=true;
        }
        else if(e.getSource()==s[currentTrial].no){
            answerTF=false;
        }


        currentTrial++;
        if(currentTrial>=s.length){
            cards.show(this, "end");
        }
        else{
            add(new sylBetween(answerTF,name), "b"+currentTrial);
            this.revalidate();
            cards.show(this, "b"+currentTrial);
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e1) {
                System.err.println(e1);
            }
            cards.show(this,"Card"+currentTrial);
        }

    }

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-05-29T11:28:20+00:00Added an answer on May 29, 2026 at 11:28 am

    You are making your event dispatcher thread wait till 3 second. This will stop the response and your action event will not return back till this time to do repainting.
    Check SwingUtilities invokeLater(), you can create a background thread and make it sleep for 3 second. once it awake , using swing utility methods you can write your UI updation code such that it will be executed by EDT.

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

Sidebar

Related Questions

I have written a program which uses a SQL exception class and then use
I have a program which i have myself written in java, but I want
I have a main program written in C# which creates and uses objects written
I have a program written in VB.NET which stops a service that uses file
I have a program written in C++ which uses dlopen to load a dynamic
I have written a program which reads input from csv file and its working
I have written sample program which uses XSLT to generate HTML response. Check below
I have written a small program which uses function pointers to do some numerical
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I am beginning to port a program which is written in C and have

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.