Here you can find the source of cascade(JDesktopPane desktopPane, int layer)
public static void cascade(JDesktopPane desktopPane, int layer)
//package com.java2s; /******************************************************************************* * Copyright (C) 2011 Atlas of Living Australia * All Rights Reserved./*from w w w. j a va 2 s. com*/ * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. ******************************************************************************/ import java.awt.Rectangle; import java.awt.Window; import javax.swing.JComponent; import javax.swing.JDesktopPane; import javax.swing.JInternalFrame; public class Main { public static void cascade(JComponent[] frames, Rectangle dBounds, int separation) { int margin = 10 * separation; int width = dBounds.width - margin; int height = dBounds.height - margin; for (int i = 0; i < frames.length; i++) { int offset = (frames.length - i - 1) * separation; int xOffset = dBounds.x + offset; if (xOffset > (dBounds.x + dBounds.width) - width) { xOffset -= margin; } int yOffset = dBounds.y + offset; if (yOffset > (dBounds.y + dBounds.height) - height) { yOffset -= margin; } frames[i].setBounds(xOffset, yOffset, width, height); } } public static void cascade(Window[] windows, Rectangle dBounds, int separation) { int margin = 10 * separation; int width = dBounds.width - margin; int height = dBounds.height - margin; for (int i = 0; i < windows.length; i++) { int offset = (windows.length - i - 1) * separation; int xOffset = dBounds.x + offset; if (xOffset > (dBounds.x + dBounds.width) - width) { xOffset -= margin; } int yOffset = dBounds.y + offset; if (yOffset > (dBounds.y + dBounds.height) - height) { yOffset -= margin; } windows[i].setBounds(xOffset, yOffset, width, height); } } public static void cascade(JDesktopPane desktopPane, int layer) { JInternalFrame[] frames = desktopPane.getAllFramesInLayer(layer); if (frames.length == 0) { return; } cascade(frames, desktopPane.getBounds(), 24); } public static void cascade(JDesktopPane desktopPane) { JInternalFrame[] frames = desktopPane.getAllFrames(); if (frames.length == 0) { return; } cascade(frames, desktopPane.getBounds(), 24); } }