Example usage for java.awt Component minimumSize

List of usage examples for java.awt Component minimumSize

Introduction

In this page you can find the example usage for java.awt Component minimumSize.

Prototype

@Deprecated
public Dimension minimumSize() 

Source Link

Document

Returns the minimum size of this component.

Usage

From source file:CircleOfSquares.java

public Dimension minimumLayoutSize(Container parent) {

    Insets parentInsets = parent.insets();
    int componentCount = parent.countComponents();
    int rowCount = rows;
    int colCount = cols;

    if (rowCount > 0) {
        colCount = (componentCount + rowCount - 1) / rowCount;
    } else {/*from   ww w  .  j  a  va  2s .co  m*/
        rowCount = (componentCount + colCount - 1) / colCount;
    }

    // Find the maximum "minimum width" and the maximum "minimum height"
    // of any component.
    int w = 0;
    int h = 0;
    for (int i = 0; i < componentCount; i++) {

        Component comp = parent.getComponent(i);
        Dimension d = comp.minimumSize();
        if (w < d.width) {
            w = d.width;
        }
        if (h < d.height) {
            h = d.height;
        }
    }

    // Return the maximum "minimum component width and height" times the number
    // of columns and rows, respectively, plus any insets in the parent.
    return new Dimension(parentInsets.left + parentInsets.right + colCount * w,
            parentInsets.top + parentInsets.bottom + rowCount * h);
}