List of usage examples for javax.swing JComponent setMinimumSize
@BeanProperty(description = "The minimum size of the component.") public void setMinimumSize(Dimension minimumSize)
From source file:Main.java
public static void set3Dimensions(JComponent c, Dimension d) { c.setMinimumSize(d); c.setPreferredSize(d);// www .j a va 2 s .c o m c.setMaximumSize(d); }
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 *//*w w w.j a v a 2 s .c om*/ 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 final void setSMPSizes(JComponent comp, Dimension d) { comp.setSize(d);/* w w w .j av a 2s .c om*/ comp.setMinimumSize(d); comp.setPreferredSize(d); }
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:Main.java
/** * Set the minimum 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 www . j ava 2s . co m*/ */ public static void setMinimumSize(Dimension d, JComponent... components) { for (JComponent c : components) { c.setMinimumSize(d); } }
From source file:Main.java
public static void setFixedSize(JComponent component, Dimension size) { component.setPreferredSize(size);/*from w w w . j a v a2s. c o m*/ component.setMinimumSize(size); component.setMaximumSize(size); component.setSize(size); }
From source file:Main.java
public static void setComponentSize(int width, int height, JComponent l) { l.setPreferredSize(new Dimension(width, height)); l.setMinimumSize(new Dimension(width, height)); if (l instanceof JTextField || l instanceof JComboBox) { l.setMaximumSize(new Dimension(Short.MAX_VALUE, height)); }// www . j a v a 2 s. c om }
From source file:Main.java
public static void forceSize(JComponent component, int width, int height) { Dimension d = new Dimension(width, height); component.setMinimumSize(d); component.setMaximumSize(d);/*from w w w .ja v a 2 s . c om*/ component.setPreferredSize(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()); }
From source file:Main.java
public static void sizeUniformly(JComponent... components) { for (JComponent c : components) { c.setPreferredSize(null);/*from ww w. ja va2s . com*/ 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); } }