Reputation: 1135
I have a class that extends javax.swing.JFrame built with NetBeans GUI editor. Is there a way to make this JFrame cascade when several of it being opened ?
Upvotes: 6
Views: 1857
Reputation: 328750
JFrame
s are top-level components, they don't nest.
If you need nested frames (i.e. frames that can be a child of another frame), use JInternalFrame instead.
If you need to create new frames in the existing application when it is invoked again, use a Socket to send the arguments for the new frame from the new application to the existing one and then exit the new application.
Upvotes: 2
Reputation: 32391
Just keep a variable with the previous such opened JFrame
location and for the next one do:
newFrame.setLocation(previousLocation.x + constant, previoudLocation.y + constant);
The getLocation()
will return you the location on screen of an existing JFrame
.
Upvotes: 2