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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:18:36+00:00 2026-05-20T22:18:36+00:00

i am using the following code : JDialog d=new JDialog(); JInternalFrame i=new JInternalFrame(HI,false,false,false,false); i.setPreferredSize(new

  • 0

i am using the following code :

      JDialog d=new JDialog();
         JInternalFrame i=new JInternalFrame("HI",false,false,false,false);
       i.setPreferredSize(new Dimension(100,100));
     d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
     d.setTitle("Wait dialog");
    d.add(i);
     d.pack();
      d.setPreferredSize(new Dimension(100,100));
        d.setLocation(300,300);
    d.setAlwaysOnTop(true);
   d.setVisible(true);

but instead of getting a jdialog of size 100*100, i am getting a small window with the default width and height , why is this happening?
note: I did the same with a JFrame , and i got the result.But i want it on a JDialog.

Thanks in advance

  • 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-20T22:18:37+00:00Added an answer on May 20, 2026 at 10:18 pm

    You need to call pack() on the JDialog after adding all components to it but before displaying it with setVisible(true).

    On an unrelated note, it would be a good idea to associate your JDialog with its parent window (possibly a JFrame) via one of the JDialog constructor overloads.

    Edit: you don’t want to add JInternalFrames directly to a JDialog or other top-level window. Instead create a JDesktopPane, set its preferredSize, add THAT to the JDialog’s contentPane and then add the JInternalFrame to the JDesktopPane.

    Edit 2: You’ll also need to set the size and position of the internal frame (setBounds will work well for this) and call setVisible(true) on the internal frame. The Swing tutorial on using internal frames and desktop panes will tell you all about this.

    Edit 3: e.g.,

    class testDialog {
    
       public static void main(String[] args) {
          JDialog d = new JDialog();
          JDesktopPane desktoppane = new JDesktopPane(); // added
          desktoppane.setPreferredSize(new Dimension(100, 100));// added
          JInternalFrame i = new JInternalFrame("HI", false, false, false, false);
          // i.setPreferredSize(new Dimension(100, 100));
          i.setBounds(0, 0, 100, 100);// added
          desktoppane.add(i);
          i.setVisible(true);
    
          d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          d.setTitle("Wait dialog");
          // d.add(i);
          d.add(desktoppane); // added
          d.pack();
          // d.setPreferredSize(new Dimension(100, 100));
          d.setLocation(300, 300);
          d.setAlwaysOnTop(true);
          d.setVisible(true);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using following code $doc = new DOMDocument(); $doc->strictErrorChecking = false; @$doc->loadHTML($data); $xpath
Using the following code: Private Sub MakeMeSomeXmlBeforeRyanGetsAngry() Dim db As New MyDBDataContext Dim customer
I created a DB using following code. Dim conn As New SqlConnection(Server=.\SQLExpress;Data Source=;Integrated Security=SSPI)
I am using following code UiApplication.getUiApplication().invokeLater(new Runnable(){ public void run(){ // your code here
I'm using following code to wait a java-script execution for 3 seconds. var test
When I am using the wait() method in the following code its throwing the
I am using following code to create new wifi access point and to connect
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,
I am using following code to check whether a check box on my website
I am using following code to design my home page. The output (as shown

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.