Example usage for javax.swing JComponent setMinimumSize

List of usage examples for javax.swing JComponent setMinimumSize

Introduction

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

Prototype

@BeanProperty(description = "The minimum size of the component.")
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 sizeIt(JComponent c, int width, int height) {
    if (height < 0) {
        height = c.getPreferredSize().height;
    }/*  w  w w. j ava2  s  .  com*/
    Dimension myDimension = new Dimension(width, height);
    c.setMaximumSize(myDimension);
    c.setMinimumSize(myDimension);
    c.setPreferredSize(myDimension);
}

From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.MetricsPlot.java

private static void setSizeOfComponent(JComponent component, Dimension dim) {
    component.setMinimumSize(dim);
    component.setMaximumSize(dim);//from  w  w w  .j  a v a  2s.  c  o  m
    component.setPreferredSize(dim);
    component.setSize(dim);
}

From source file:net.sourceforge.doddle_owl.utils.Utils.java

public static JComponent createTitledPanel(JComponent component, String title, int width, int height) {
    component.setPreferredSize(new Dimension(width, height));
    component.setMinimumSize(new Dimension(width, height));
    return createTitledPanel(component, title);
}

From source file:com.atlassian.theplugin.idea.bamboo.tree.BuildTreeNode.java

private static void setFixedComponentSize(JComponent c, int width, int height) {
    c.setPreferredSize(new Dimension(width, height));
    c.setMinimumSize(new Dimension(width, height));
    c.setMaximumSize(new Dimension(width, height));
}

From source file:events.ListDataEventDemo.java

/** 
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./*from   w w  w . j  a v  a  2 s.  c o m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("ListDataEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new ListDataEventDemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Don't let the content pane get too small.
    //(Works if the Java look and feel provides
    //the window decorations.)
    newContentPane.setMinimumSize(new Dimension(newContentPane.getPreferredSize().width, 100));

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from w  w w  .ja  v  a2s  .  c  o  m
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("ListDataEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new Main();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Don't let the content pane get too small.
    // (Works if the Java look and feel provides
    // the window decorations.)
    newContentPane.setMinimumSize(new Dimension(newContentPane.getPreferredSize().width, 100));

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:ListDataEventDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//*  w w  w . j  a  v a  2 s . c  o  m*/
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("ListDataEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new ListDataEventDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Don't let the content pane get too small.
    // (Works if the Java look and feel provides
    // the window decorations.)
    newContentPane.setMinimumSize(new Dimension(newContentPane.getPreferredSize().width, 100));

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from w  ww.j  a  v a  2  s .c om
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("ListDataEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new Main();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Don't let the content pane get too small.
    //(Works if the Java look and feel provides
    //the window decorations.)
    newContentPane.setMinimumSize(new Dimension(newContentPane.getPreferredSize().width, 100));

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

private Component createStrut() {
    JComponent component = (JComponent) Box.createHorizontalStrut(5);
    component.setMinimumSize(new Dimension(0, 0));
    component.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    return component;
}

From source file:com.limegroup.gnutella.gui.GUIUtils.java

public static void restrictSize(JComponent component, SizePolicy sizePolicy, boolean addClientProperty) {
    switch (sizePolicy) {
    case RESTRICT_HEIGHT:
        int height = component.getPreferredSize().height;
        int width = component.getPreferredSize().width;
        component.setMinimumSize(new Dimension(width, height));
        //component.setPreferredSize(new Dimension(width, height));
        component.setMaximumSize(new Dimension(Integer.MAX_VALUE, height));
        break;/*ww  w .j  a  v a  2 s.c o  m*/
    case RESTRICT_BOTH:
        height = component.getPreferredSize().height;
        width = component.getPreferredSize().width;
        component.setMinimumSize(new Dimension(width, height));
        //component.setPreferredSize(STANDARD_DIMENSION);
        component.setMaximumSize(new Dimension(width, height));
        break;
    case RESTRICT_NONE:
        component.setMinimumSize(null);
        component.setMaximumSize(null);
    }
    if (addClientProperty) {
        component.putClientProperty(SizePolicy.class, sizePolicy);
    }
}