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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:57:32+00:00 2026-06-02T10:57:32+00:00

My application is using JOptionPane s at some points for input of information. At

  • 0

My application is using JOptionPanes at some points for input of information.
At the same time that JOptionPane is shown, changes can happen on the GUI that are made from other clients over the network. These can be text on JTextArea, or nodes changing on JTree.

Does that mean that I need to create the JOptionPane on a new thread so that I will not have problems on the changes made during JOptionPane is active?

I looked on a few places on internet but I did not get a clear answer.

p.s JOptionPane is created when a user clicks on a button.

  • 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-02T10:57:34+00:00Added an answer on June 2, 2026 at 10:57 am

    Swing is single threaded, so the option of ‘using another thread’ is simply not an option. However, that does not mean your components can not be updated while the option pane is shown. See below for an example. I added a System.out call to illustrate that the JOptionPane call is blocking, but due to the Swing timer I can append text to my JTextArea (on the EDT).

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.Timer;
    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    public class UpdateOptionPane {
    
      private static void showUI(){
        final JFrame testFrame = new JFrame( "TestFrame" );
    
        final JTextArea textArea = new JTextArea(  );
        testFrame.add( new JScrollPane( textArea ), BorderLayout.CENTER );
    
        Timer timer = new Timer( 1000, new ActionListener() {
          @Override
          public void actionPerformed( ActionEvent e ) {
            textArea.append( "bla" );
          }
        } );
        timer.setRepeats( true );
        timer.start();
        JButton button = new JButton( "Click me" );
        button.addActionListener( new ActionListener() {
          @Override
          public void actionPerformed( ActionEvent e ) {
            System.out.println("Before option pane");
            JOptionPane.showMessageDialog( testFrame, "A message dialog" );
            System.out.println("After option pane");
          }
        } );
        testFrame.add( button, BorderLayout.SOUTH );
        testFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        testFrame.pack();
        testFrame.setVisible( true );
      }
    
      public static void main( String[] args ) {
        EventQueue.invokeLater( new Runnable() {
          @Override
          public void run() {
            showUI();
          }
        } );
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our Swing application, we show error messages using JOptionPane.showOptionDialog . However, some of
I'm creating a gui application that requires some simple input, however, when I click
i am developing an application using c#.net in which i need that if a
I make a java application using netbeans that connect to database , but i
I am building an application using the Backbone Boilerplate , and am having some
am using OCUnit to test my application however am running into some trouble. When
Trying to deploy application using ClickOnce to a webserver running sharepoint. I can publish
I am developing an Application using vc++ and C# ,the application can Import and
I have created an application using Netbeans 6.9. In the application I want that
If I write an application using the Android SDK or NDK, can I simply

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.