Java JDesktopPane arrangeIcons(JDesktopPane desktop)

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

Description

arrange Icons

License

Open Source License

Declaration

public static final int arrangeIcons(JDesktopPane desktop) 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.awt.Dimension;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;

public class Main {
    public static final int arrangeIcons(JDesktopPane desktop) {
        int _iconCnt = 0;
        JInternalFrame _allFrames[] = desktop.getAllFrames();
        for (int _x = 0; _x < _allFrames.length; _x++) {
            if ((_allFrames[_x].isVisible()) && (_allFrames[_x].isIcon())) {
                _iconCnt++;//from www . jav a2 s.  com
            }
        }
        int _height = desktop.getBounds().height;
        int _yPos = _height;
        if (_iconCnt != 0) {
            int _width = desktop.getBounds().width;
            int _xPos = 0;
            for (int _x = 0; _x < _allFrames.length; _x++) {
                JInternalFrame _frame = _allFrames[_x];
                if ((_frame.isVisible()) && (_frame.isIcon())) {
                    Dimension _dim = _frame.getDesktopIcon().getSize();
                    int _iWidth = _dim.width;
                    int _iHeight = _dim.height;
                    if (_yPos == _height) {
                        _yPos = _height - _iHeight;
                    }
                    if ((_xPos + _iWidth > _width) && (_xPos != 0)) {
                        _xPos = 0;
                        _yPos -= _iHeight;
                    }
                    _frame.getDesktopIcon().setLocation(_xPos, _yPos);
                    _xPos += _iWidth;
                } // End if
            } // End for
        } // End if
        return (_yPos);
    }
}

Related

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