Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 266
Onca Avatar asked Aug 27 '12 15:08

Onca


3 Answers

Use setLocationByPlatform(true).

like image 190
Andrew Thompson Avatar answered Nov 05 '22 10:11

Andrew Thompson


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.

like image 33
Dan D. Avatar answered Nov 05 '22 09:11

Dan D.


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.

like image 2
Aaron Digulla Avatar answered Nov 05 '22 09:11

Aaron Digulla