Example usage for java.awt Dimension Dimension

List of usage examples for java.awt Dimension Dimension

Introduction

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

Prototype

public Dimension(Dimension d) 

Source Link

Document

Creates an instance of Dimension whose width and height are the same as for the specified dimension.

Usage

From source file:Main.java

/**
 * Returns dimension copy.//from   www .  j  ava 2  s  .c  om
 *
 * @param dimension
 *            dimension to copy
 * @return dimension copy
 */
public static Dimension copy(final Dimension dimension) {
    return new Dimension(dimension);
}

From source file:Main.java

public static void constrainResize(ComponentEvent componentevent) {
    Component component = componentevent.getComponent();
    Dimension dimension = component.getSize();
    Dimension dimension1 = component.getMinimumSize();
    Dimension dimension2 = new Dimension(dimension);
    boolean flag = false;
    if (dimension.width < dimension1.width) {
        flag = true;/*from  w  w w  . ja v  a 2s . c  om*/
        dimension2.width = dimension1.width;
    }
    if (dimension.height < dimension1.height) {
        flag = true;
        dimension2.height = dimension1.height;
    }
    if (flag)
        component.setSize(dimension2);
}