Java JDesktopPane arrangeMinifiedWindows(JDesktopPane desktop)

Here you can find the source of arrangeMinifiedWindows(JDesktopPane desktop)

Description

arrange Minified Windows

License

Open Source License

Declaration

public static void arrangeMinifiedWindows(JDesktopPane desktop) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2011 Atlas of Living Australia
 * All Rights Reserved.//from ww  w.  j  a v  a2 s  .co m
 * 
 * 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.Point;
import java.awt.Rectangle;

import java.util.ArrayList;

import java.util.List;

import javax.swing.JDesktopPane;

import javax.swing.JInternalFrame;
import javax.swing.JInternalFrame.JDesktopIcon;

public class Main {
    public static void arrangeMinifiedWindows(JDesktopPane desktop) {
        List<JInternalFrame> minified = new ArrayList<JInternalFrame>();
        JInternalFrame[] frames = desktop.getAllFrames();
        for (JInternalFrame frame : frames) {
            if (frame.isIcon()) {
                minified.add(frame);
            }
        }

        if (minified.size() > 0) {

            Rectangle desktopBounds = desktop.getBounds();

            JDesktopIcon i = minified.get(0).getDesktopIcon();
            Rectangle bounds = i.getBounds();
            int x = 0;
            int y = desktopBounds.height - bounds.height;

            for (JInternalFrame f : minified) {
                JDesktopIcon icon = f.getDesktopIcon();
                icon.setLocation(new Point(x, y));
                x += bounds.width;
                if (x + bounds.width > desktopBounds.width) {
                    x = 0;
                    y -= bounds.height;
                }
            }
        }

    }
}

Related

  1. arrangeIcons(JDesktopPane desktop)
  2. cascade(JDesktopPane desktopPane, int layer)
  3. makeCenter(JDesktopPane desktop)
  4. moveOff(JDesktopPane desktop)
  5. tileHorizontal(JDesktopPane desktop)