import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.beans.*; public class TileAction extends AbstractAction { private JDesktopPane desk; public TileAction(JDesktopPane desk) { super("Tile Frames"); this.desk = desk; } public void actionPerformed(ActionEvent ev) { JInternalFrame[] allframes = desk.getAllFrames(); int count = allframes.length; if (count==0) return; int sqrt = (int)Math.sqrt(count); int rows = sqrt; int cols = sqrt; if(rows*cols < count) { cols++; if(rows*cols < count) { rows++; } } Dimension size = desk.getSize(); int w = size.width/cols; int h = size.height/rows; int x = 0; int y = 0; for(int i=0; i