Hy,
I have a JFrame main window and a Dialog window, how can i use the method setPositionRelativeTo() so that my Dialog window positions centered on the main window ?
Thanks
claudiu_is
0
Light Poster
Recommended Answers
Jump to PostIf you pass the JFrame reference as the "owner" parameter to the JDialog constructor it will center on it. Example:
JFrame frame = new JFrame(); frame.setBounds(200,200,300, 400); frame.setVisible(true); JDialog dialog = new JDialog(frame,"test"); dialog.setVisible(true);
Jump to Postmy Dialog class is used inside the main window class, so i`m using "this" in Dialog`s object constructor, but the Dialog window is not centered;
please let me know if you want to post the codeYes, the code would probably help. If your main window class extends JFrame and …
Jump to PostThe dialog is centered in the frame when I click the button. Where is it appearing for you?
All 9 Replies
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
claudiu_is
0
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
claudiu_is
0
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
claudiu_is
0
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
claudiu_is
0
Light Poster
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.