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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:49:38+00:00 2026-05-18T19:49:38+00:00

I have banking gui application that I am currently working on and there seems

  • 0

I have banking gui application that I am currently working on and there seems to be a problem with the setvisible method for my jdialog. After the user has withdrawn a valid amount I pop up a simple dialog that says “transaction in progress”. In my dobackground method i keep polling to check if the transaction has been received. I tried using swingworker and I don’t understand why it’s not working. If i remove the setvisible call it works fine, so why does setvisible cause the system to hang? Here is the code that is inside my jbutton mouselistener:

SwingWorker<String,Integer> worker = new SwingWorker<String,Integer>(){

  JDialog waitForTrans = new JDialog((JFrame)null,true);
  public String doInBackground() throws Exception {
     waitForTrans.add(new JLabel("Updating balance in system. Please Wait..."));
     waitForTrans.setMinimumSize(new Dimension(300,100));
     waitForTrans.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
     waitForTrans.setVisible(true);
     Bank.getInstance().sendTransaction(currentPin,"-"+withdraw);
     while(!Bank.getInstance().hasCompletedTransaction){

     }
     return null;

  }

  public void done(){
   try {
        this.get();
       } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {

        e.printStackTrace();
    }
    waitForTrans.setVisible(false);
    newField.setText(String.valueOf(Bank.getInstance().getAccountList().get(currentPin).getBalance()));
  }

 };
 worker.execute();
  • 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-18T19:49:39+00:00Added an answer on May 18, 2026 at 7:49 pm

    First, it is recommended to do all the GUI updates in the Swing Event-Dispatch thread, i.e. using the SwingUtilites class.

    Second, your JDialog is modal and so blocks the thread in which the setVisible(true) method is called (in your case the Main thread, in the following case the Swing Event-Dispatch Thread).

    I do not say the following code is perfect, but it should put you on the track…

    
    final JDialog waitForTrans = new JDialog((JFrame) null, true);
    
    SwingWorker worker = new SwingWorker() {
    
      public String doInBackground() throws Exception {
        Thread.sleep(5000);
        return null;
      }
    
      public void done() {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            waitForTrans.setVisible(false);
            waitForTrans.dispose();
          }
        });
      }
    
    };
    
    worker.execute();
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        waitForTrans.add(new JLabel("Please Wait..."));
        waitForTrans.setMinimumSize(new Dimension(300, 100));
        waitForTrans.setVisible(true);
      }
    });
    
    

    Hope this helps.

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

Sidebar

Related Questions

I'm currently working on a simple banking application. I have built a postgresql database,
I have a simple (and also trivial) banking application that I wrote in C++.
Currently we have a project to implement an Internet Banking site, and we are
I have an assignment to use JavaBeans to create an online Banking application. I
I noticed that many websites, even Google and some banking sites, have poorly-written HTML
Assume that you are doing a banking application. If users are logged into your
I'm working on a pretty tricky problem that I've been on for literally a
There is a banking site that I cannot login to unless I allow all
I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New
I have a problem with selectInputDate: I have a backing bean which 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.