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

Recommended Answers

All 2 Replies

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.