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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:57:13+00:00 2026-06-03T13:57:13+00:00

Hi noticed some code in our application when I first started Java programming. I

  • 0

Hi noticed some code in our application when I first started Java programming. I had noticed it created a dialog from a separate thread, but never batted an eye lid as it ‘seemed to work’. I then wrapped this method up through my code to display dialogs.

This is as follows:

public class DialogModalVisibleThread
        extends Thread {
    private JDialog jDialog;
    public DialogModalVisibleThread(JDialog dialog, String dialogName) {
        this.setName("Set " + dialogName + " Visable");
        jDialog = dialog;
    }

    @Override
    public void run() {
       jDialog.setVisible(true);
       jDialog.requestFocus();
    }
}

Usage:

WarnUserDifferenceDialog dialog = new WarnUserDifferenceDialog( _tableDifferenceCache.size() );
DialogModalVisibleThread dmvt = new DialogModalVisibleThread( dialog, "Warn User About Report Diffs");
dmvt.start();

Now, as far as I am now aware, you should never create or modify swing components from a separate thread. All updates must be carried out on the Event Dispatch Thread. Surely this applies to the above code?

EDT on WikiPedia

However, the above code has worked.

But lately, there have been countless repaint issues. For example, click on a JButton which then calls DialogModalVisibleThread to display a dialog. It caused buttons alongside the clicked button not to redraw properly.

The repaint problem is more frequent on my machine and not the other developers machine. The other developer has a laptop with his desktop extended onto a 21″ monitor – the monitor being his main display. He is running Windows 7 with Java version 1.6.0_27.

I am running on a laptop with Windows 7 and Java version 1.6.0_24. I have 2 additional monitors with my desktop extended onto both.

In the meantime I am going to upgrade to Java 1.6 update 27.

I wondered if the above code could cause repaint problems or are there any other people out there with related paint issues?

Are there any easy ways to diagnose these problems?

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-03T13:57:14+00:00Added an answer on June 3, 2026 at 1:57 pm

    So, you’re breaking a rule, having problems, and wondering if these problems could be cause by the fact that you broke the rule. The answer is Yes. Respect the rules!

    To detect the violations, you might be interested by the following page: http://weblogs.java.net/blog/2006/02/16/debugging-swing-final-summary

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

Sidebar

Related Questions

I recently released some code to our production website and I noticed that IIS
I noticed for a while now the following syntax in some of our code:
I looked through some code and noticed that the convention was to turn pointer
I was looking at some code by an individual and noticed he seems to
I saw this in some code: $(<p/>).append(<div>something</div>).appendTo(body); and noticed that it automatically closed the
I'm looking into writing simple graphics code in Android and I've noticed some synchronized()
In some Delphi 7 code I am maintaining, I've noticed a lot of instances
I was looking through some compiled coffee-script code, and I noticed something like the
I noticed some odd behaviour when using the strongly typed HtmlHelper.ActionLink() extension method from
Some of our non-technical users are having problems where a dialog MessageBox in our

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.