Example usage for javax.swing JComponent getMinimumSize

List of usage examples for javax.swing JComponent getMinimumSize

Introduction

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

Prototype

@Transient
public Dimension getMinimumSize() 

Source Link

Document

If the minimum size has been set to a non-null value just returns it.

Usage

From source file:Main.java

public static int getMinimumWidth(JComponent component) {

    return (int) component.getMinimumSize().getWidth();
}

From source file:Main.java

public static int getMinimumHeight(JComponent component) {

    return (int) component.getMinimumSize().getHeight();
}

From source file:Main.java

/**
 * Freezes the width of the given component to the given size, preventing
 * it from expanding to fill any additional space.
 * @param component the component to freeze
 * @param width the width to freeze the component to
 * @return the component passed in, for chaining purposes
 *//*from w  w w.ja  va  2s .com*/
public static JComponent freezeWidth(JComponent component, int width) {
    component.setMinimumSize(new Dimension(width, component.getMinimumSize().height));
    component.setPreferredSize(new Dimension(width, component.getPreferredSize().height));
    component.setMaximumSize(new Dimension(width, component.getMaximumSize().height));
    return component;
}

From source file:Main.java

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

    component.setMinimumSize(new Dimension((int) component.getMinimumSize().getWidth(), height));
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java

private void adjustViewPreferredSize() {
    JComponent view = DesktopComponentsHelper.getComposition(content);
    Dimension minimumSize = view.getMinimumSize();
    Dimension preferredSize = null;
    switch (scrollBarPolicy) {
    case VERTICAL:
        preferredSize = new Dimension(impl.getViewport().getWidth(), minimumSize.height);
        break;/*from   www.  ja v a 2s.  c o  m*/

    case HORIZONTAL:
        preferredSize = new Dimension(minimumSize.width, impl.getViewport().getHeight());
        break;

    case NONE:
        preferredSize = new Dimension(impl.getViewport().getWidth(), impl.getViewport().getHeight());
        break;

    case BOTH:
        preferredSize = new Dimension(minimumSize.width, minimumSize.height);
        break;
    }
    view.setPreferredSize(preferredSize);

    requestRepaint();
}