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++) {
  ifs[i].setBounds(
     i*20
     ,i*20
     ,200
     ,200
   );
}

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact