Example usage for java.awt Component setMaximumSize

List of usage examples for java.awt Component setMaximumSize

Introduction

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

Prototype

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 removeFixedSize(Component c) {
    c.setMinimumSize(new Dimension(0, 0));
    c.setMaximumSize(new Dimension(65535, 65535));
}

From source file:Main.java

/** Sets maximum width of the component, leaving the height intact. */
public static void setMaximumWidth(Component component, int width) {
    Dimension dim = component.getMaximumSize();
    component.setMaximumSize(new Dimension(width, dim.height));
}

From source file:Main.java

public static void setSizes(Component comp, Dimension dim) {
    comp.setMinimumSize(dim);// w  w  w  .j av a2s . c o  m
    comp.setPreferredSize(dim);
    comp.setMaximumSize(new Dimension(Short.MAX_VALUE, (int) comp.getPreferredSize().getHeight()));
}

From source file:Main.java

private static void doSetSizeInEDT(final Component component, final int width, final int height) {
    component.setMaximumSize(new Dimension(width, height));
    component.setMinimumSize(new Dimension(width, height));
    component.setPreferredSize(new Dimension(width, height));
    component.setSize(new Dimension(width, height));
}

From source file:Main.java

public static void setForcedSize(Component comp, Dimension dim) {
    comp.setMinimumSize(dim);/*from   ww w .  ja  v  a 2 s.co  m*/
    comp.setPreferredSize(dim);
    comp.setMaximumSize(dim);
}

From source file:Main.java

public static void setSize(final Component component, final int width, final int height) {
    if (component != null && width >= 0 && height >= 0) {
        runInEDT(() -> {/*  w w  w.j  a  v  a2  s .c  om*/
            component.setMaximumSize(new Dimension(width, height));
            component.setMinimumSize(new Dimension(width, height));
            component.setPreferredSize(new Dimension(width, height));
            component.setSize(new Dimension(width, height));
        });
    }
}

From source file:Main.java

public static void setMaxSizePercent(final Component c, float widthPercent, float heightPercent) {
    final Dimension screenDimensions = Toolkit.getDefaultToolkit().getScreenSize();
    float fWidth = ((float) screenDimensions.width) * widthPercent;
    float fHeight = ((float) screenDimensions.height) * heightPercent;
    c.setMaximumSize(new Dimension((int) fWidth, (int) fHeight));
}

From source file:Main.java

public void addToToolbar(Component component, int row, int column) {
    Dimension d = component.getPreferredSize();
    component.setMaximumSize(d);
    component.setMinimumSize(d);/* ww w . j ava 2 s.  c  o  m*/
    component.setPreferredSize(d);
    toolbar.add(component);

}

From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java

/**
 * Add a component to Form at position pointer by cursor, 
 * Increments cursor by one./*from   w  w  w. j a v  a2 s  . c  om*/
 * @param c Component to add
 */
public void add(Component c) {
    if (debug) {
        if (c instanceof JComponent)
            ((JComponent) c).setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    }
    addBox(c);

    if (rowHeight < Short.MAX_VALUE) {
        Dimension d = c.getPreferredSize();
        d.height = rowHeight;
        c.setPreferredSize(d);

        c.setMinimumSize(d);

        if (!c.isMaximumSizeSet() || c.getMaximumSize().getHeight() > rowHeight) {
            c.setMaximumSize(new Dimension(Short.MAX_VALUE, rowHeight));
        }
    }

}

From source file:com.moneydance.modules.features.importlist.table.HeaderRenderer.java

@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
        final boolean hasFocus, final int row, final int column) {
    Component component = this.defaultHeaderTableCellRenderer.getTableCellRendererComponent(table, value,
            hasFocus, hasFocus, row, column);
    if (component instanceof JComponent) {
        JComponent jComponent = (JComponent) component;
        jComponent.setBorder(new EmptyBorder(1, 1, 1, 1));
        jComponent.setOpaque(false);//w  w w  . j a  va  2  s  .c  o  m

        if (jComponent instanceof JLabel) {
            JLabel jLabel = (JLabel) jComponent;
            jLabel.setHorizontalAlignment(SwingConstants.LEFT);
        }
    }

    component.setFont(Preferences.getHeaderFont());
    component.setForeground(Preferences.getHeaderForeground());

    component.setSize(
            new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight()));
    component.setMinimumSize(
            new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight()));
    component.setPreferredSize(
            new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight()));
    component.setMaximumSize(
            new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight()));

    return component;
}