Example usage for java.awt Component setMinimumSize

List of usage examples for java.awt Component setMinimumSize

Introduction

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

Prototype

public void setMinimumSize(Dimension minimumSize) 

Source Link

Document

Sets the minimum 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

public static void setSizes(Component comp, Dimension dim) {
    comp.setMinimumSize(dim);
    comp.setPreferredSize(dim);//from ww w. ja va  2 s  .  c om
    comp.setMaximumSize(new Dimension(Short.MAX_VALUE, (int) comp.getPreferredSize().getHeight()));
}

From source file:Main.java

public static void setForcedSize(Component comp, Dimension dim) {
    comp.setMinimumSize(dim);
    comp.setPreferredSize(dim);/*w w w.  j  a  v  a 2s .  com*/
    comp.setMaximumSize(dim);
}

From source file:Main.java

/**
 * Sets the minimum size of the given components to the maximum size
 * of the given components./*  ww w  .j  a v a 2 s.co  m*/
 * @param components the components to size
 */
public static final void setMinimumSize(Component... components) {
    Dimension size = getMaximumSize(components);
    for (Component component : components) {
        component.setMinimumSize(size);
    }
}

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 setSize(final Component component, final int width, final int height) {
    if (component != null && width >= 0 && height >= 0) {
        runInEDT(() -> {//from   ww  w .java  2s  .c  o  m
            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 void addToToolbar(Component component, int row, int column) {
    Dimension d = component.getPreferredSize();
    component.setMaximumSize(d);/*from w w  w .j av a  2 s  .com*/
    component.setMinimumSize(d);
    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   ww  w.jav a  2  s .co  m*/
 * @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);//from w  ww.j a  v  a  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;
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * //from   w w  w.ja v  a 2  s . co  m
 */
protected void createUI() {
    JTabbedPane tabbedPane = new JTabbedPane();

    rp = new RegProcessor();
    rp.processSQL();

    tree = new JTree(rp.getRoot(INCL_ANON));
    propsTable = new JTable();

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            fillPropsTable();
        }
    });
    tree.setCellRenderer(new MyTreeCellRenderer());

    Component topComp = UIHelper.createScrollPane(tree);
    Component botComp = UIHelper.createScrollPane(propsTable);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);

    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    splitPane.setLastDividerLocation(300);
    Dimension minimumSize = new Dimension(200, 400);
    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    tabbedPane.add("Registration", splitPane);

    final List<Pair<String, String>> trackDescPairs = rp.getTrackKeyDescPairs();
    Vector<String> trkItems = new Vector<String>();
    for (Pair<String, String> p : trackDescPairs) {
        trkItems.add(p.second);
    }

    //Collections.sort(trkItems);
    final JList list = new JList(trkItems);
    //pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1));
    list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int inx = list.getSelectedIndex();
                if (inx > -1) {
                    fillUsageItemsList(trackDescPairs.get(inx).first);
                }
            }
        }
    });

    tabbedPane.add("Reg Stats", getStatsPane("Registration", rp.getRegNumHash().values(), "register"));

    DefaultListModel model = new DefaultListModel();
    trackItemsList = new JList(model);

    topComp = UIHelper.createScrollPane(list);
    botComp = UIHelper.createScrollPane(trackItemsList);
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp);
    splitPane.setDividerLocation(0.5);
    splitPane.setOneTouchExpandable(true);

    topComp.setMinimumSize(minimumSize);
    botComp.setMinimumSize(minimumSize);

    splitPane.setDividerLocation(0.5);
    trackUsageHash = rp.getTrackCatsHash();
    tabbedPane.add("Usage Tracking", splitPane);

    tabbedPane.add("User Stats", getStatsPane("Tracking", rp.getTrackIdHash().values(), "track"));

    add(tabbedPane, BorderLayout.CENTER);
}