When using a JDialog how can I tell it where to open on the screen? Let's say I want to open it in the middle.

Can I add a JDialog to a pane in a JFrame?


A link to the proper java doc would be great.


Thanks in advance

The Javadoc is accessible from http://java.sun.com but you should really download and install it.

Like with all Windows you can call setBounds() on it to set the position and size.

A JDialog cannot exist INSIDE another component, it can exist as a child of one.

I'd personally rather use setLocation(int x, int y). I like using the setSize() property for the overall container and using setBounds(int,int,int,int) for inner containers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.