Onca
Onca

Reputation: 1135

Java cascading JFrames

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

Answers (3)

Aaron Digulla
Aaron Digulla

Reputation: 328750

JFrames 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

Andrew Thompson
Andrew Thompson

Reputation: 168845

Use setLocationByPlatform(true).

Upvotes: 5

Dan D.
Dan D.

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

Related Questions