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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:49:22+00:00 2026-06-06T17:49:22+00:00

Edited with a SSCCE and a workaround I want to programmatically change the location

  • 0

Edited with a SSCCE and a workaround

I want to programmatically change the location of a JDialog.

public class SSCCE {
  public static void main(String[] pArgs) {
    JDialog dialog = new JDialog();
    dialog.setSize(300, 300);
    dialog.setLocation(10, 10);
    dialog.setVisible(true);
  }
}

However, this is not working, the new dialog is always located in the center of the screen. I suspect it has something todo with my L&F (Windows 7 64bit, jdk 1.6_30), when setting the dialog to be undecorated,

public class SSCCEWorksButUndecorated {
  public static void main(String[] pArgs) {
    JDialog dialog = new JDialog();
    dialog.setSize(300, 300);
    dialog.setLocation(10, 10);
    dialog.setUndecorated(true);
    dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
    dialog.setVisible(true);
  }
}

The location is excalty where I specified.

But I need a decorated dialog, has anyone else seen this problem before or am I missing something?

Workaround by settings location after setVisible() for modal dialogs

public class SSCCEWorkaroundForModalDialogs {
  public static void main(String[] pArgs) {
    final JDialog dialog = new JDialog();
    dialog.setSize(300, 300);
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        dialog.setLocation(10, 10);
      }
     });        
     dialog.setVisible(true);
  }
}
  • 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-06T17:49:24+00:00Added an answer on June 6, 2026 at 5:49 pm

    The move method documentation says:

    This method changes layout-related information, and therefore,
    invalidates the component hierarchy.

    The method changes the geometry-related data. Therefore, the native
    windowing system may ignore such requests, or it may modify the
    requested data, so that the Window object is placed and sized in a way
    that corresponds closely to the desktop settings.

    I assume you can do a call to revalidaite() before setting the dialog visible again.

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

Sidebar

Related Questions

Edited // I want to detect flash support ( not user string agent )
Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
(EDITED) Hello, In the form below, the field for <div class=urlfield><input name=url type=url id=url
Edited my code to use WebClient...still doesnt work string hhtmlurl = /Thumbnail.aspx?productID=23&Firstname=jimmy&lastnight=smith; string strFileName
(edited) I want to display a dynamic list of JPanels that hold textfield that
EDITED : The problem is with the function 'find_callback', I want to insert each
Edited because I'm a moron. Should have said class originally. I have the code
/* Edited to make sense! */ I 900 lines of this: ;745;ref;name;Adress;zipcode;;mobphone;;;;;;;;; i want
(edited from original post to change BaseMessage to const BaseMessage&) Hello All, I'm very
Edited : How do I programmatically add programs to launch on user session startup

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.