Example usage for javax.swing JComponent setMaximumSize

List of usage examples for javax.swing JComponent setMaximumSize

Introduction

In this page you can find the example usage for javax.swing JComponent setMaximumSize.

Prototype

@BeanProperty(description = "The maximum size of the component.")
public void setMaximumSize(Dimension maximumSize) 

Source Link

Document

Sets the maximum size of this component to a constant value.

Usage

From source file:Main.java

public static void setMaxWidth(JComponent comp, int width) {
    comp.setMaximumSize(new Dimension(width, Short.MAX_VALUE));
}

From source file:Main.java

public static void setMaximumWidth(JComponent component, int width) {

    component.setMaximumSize(new Dimension(width, (int) component.getMaximumSize().getHeight()));
}

From source file:Main.java

public static void setMaximumHeight(JComponent component, int height) {

    component.setMaximumSize(new Dimension((int) component.getMaximumSize().getWidth(), height));
}

From source file:Main.java

/**
 * Set the maximum size of the given components.  Intended to reduce clutter in GUI code.
 * For Java 1.4 compatibility, the arguments must be {@code JComponent}s, not arbitrary
 * {@code Component}s.//from ww  w . ja v  a  2 s  .c o  m
 */
public static void setMaximumSize(Dimension d, JComponent... components) {
    for (JComponent c : components) {
        c.setMaximumSize(d);
    }
}

From source file:Main.java

public static void set3Dimensions(JComponent c, Dimension d) {
    c.setMinimumSize(d);/*from www  .  jav  a  2 s . com*/
    c.setPreferredSize(d);
    c.setMaximumSize(d);
}

From source file:Main.java

public static void setFixedSize(JComponent component, Dimension size) {
    component.setPreferredSize(size);//from  ww  w.ja v  a  2  s. c  o  m
    component.setMinimumSize(size);
    component.setMaximumSize(size);
    component.setSize(size);
}

From source file:Main.java

private static void setSizes(java.util.List<JComponent> aComponents, Dimension aDimension) {
    Iterator<JComponent> compsIter = aComponents.iterator();
    while (compsIter.hasNext()) {
        JComponent comp = (JComponent) compsIter.next();
        comp.setPreferredSize((Dimension) aDimension.clone());
        comp.setMaximumSize((Dimension) aDimension.clone());
    }//from w  w  w.j a v a 2  s  . com
}

From source file:Main.java

public static void forceSize(JComponent component, int width, int height) {
    Dimension d = new Dimension(width, height);
    component.setMinimumSize(d);//w ww  . j  a  v  a 2 s.c om
    component.setMaximumSize(d);
    component.setPreferredSize(d);
}

From source file:Main.java

public static void sizeUniformly(JComponent... components) {

    for (JComponent c : components) {
        c.setPreferredSize(null);/*  w w w  .  j  a v  a2s  .co m*/
        c.setMinimumSize(null);
        c.setMaximumSize(null);
    }

    int width = 0;
    int height = 0;

    for (JComponent c : components) {
        Dimension d = c.getPreferredSize();
        if (d.width > width) {
            width = d.width;
        }
        if (d.height > height) {
            height = d.height;
        }
    }

    for (JComponent c : components) {
        Dimension d = c.getPreferredSize();
        d.width = width;
        d.height = height;
        c.setPreferredSize(d);
        c.setMinimumSize(d);
        c.setMaximumSize(d);
    }
}

From source file:Main.java

public static void setComponentSize(JComponent comp, int width, int height) {
    comp.setPreferredSize(new Dimension(width, height));
    comp.setMinimumSize(comp.getPreferredSize());
    comp.setMaximumSize(comp.getPreferredSize());
}