How do I cascade and tile internal frames in Swing?

Sandip Chitale

There is an example of how to tile internalframes in the book 'Java Swing' by Robert Eckstein, Marc Loy and Dave Wood. See chapter nine. It basically uses the 'square root of a square integer immediately larger than the number of InternalFrames' strategy to calculate number of rows/columns to get most 'squarish' tile.

The cascading should be simple. You have to cycle through the internalframes using a for loop over the JDesktopPane.getAllFrames()[] array. Position and size them so that they cascade using the setbounds call -

// something like this
JInternalFrame ifs[] = desktopPane.getAllFrames();
for (int i = 0; i < ifs.length; i++) {