List of usage examples for javax.swing JComponent getPreferredSize
@Transient
public Dimension getPreferredSize()
preferredSize
has been set to a non-null
value just returns it. From source file:Main.java
/** * This method encapsulates some ugly code. * It sets the preferred width of a component while keeping the preferred height intact. *//*from w w w .j a va2 s.com*/ public static void setPreferredWidth(JComponent comp, int width) { Dimension preferredSize = comp.getPreferredSize(); preferredSize.width = width; comp.setPreferredSize(preferredSize); }
From source file:Main.java
public static int getPreferredHeight(JComponent component) { return (int) component.getPreferredSize().getHeight(); }
From source file:Main.java
public static void setComponent3Width(JComponent c, int width) { Dimension d = new Dimension(width, c.getPreferredSize().height); set3Dimensions(c, d);/*from ww w .j av a 2s . c o m*/ }
From source file:Main.java
/** * Fixes the height of the component but maintaining it old width. * * @param comp/*from w w w . ja v a 2s. com*/ * @param height */ public static void fixHeight(JComponent comp, int height) { comp.setPreferredSize(new Dimension(comp.getPreferredSize().width, height)); }
From source file:Main.java
/** * Freezes the width of the given component, preventing it from expanding * to fill any additional space.//from w w w.j ava2 s. co m * @param component the component to freeze * @return the component passed in, for chaining purposes */ public static JComponent freezeWidth(JComponent component) { return freezeWidth(component, component.getPreferredSize().width); }
From source file:Main.java
public static void setPreferredWidth(JComponent component, int width) { component.setPreferredSize(new Dimension(width, component.getPreferredSize().height)); }
From source file:Main.java
public static void sizeIt(JComponent c, int width, int height) { if (height < 0) { height = c.getPreferredSize().height; }//from w w w . j a va 2 s. c om Dimension myDimension = new Dimension(width, height); c.setMaximumSize(myDimension); c.setMinimumSize(myDimension); c.setPreferredSize(myDimension); }
From source file:Main.java
/** * Sets the preferred height of the specified component. * * @param component// w w w . j a va2 s. c o m * The component * @param height * The preferred height */ public static void setPreferredHeight(final JComponent component, final int height) { component.setPreferredSize(new Dimension(component.getPreferredSize().width, height)); }
From source file:Main.java
public static void setPreferredHeight(JComponent component, int height) { component.setPreferredSize(new Dimension((int) component.getPreferredSize().getWidth(), height)); }
From source file:Main.java
public static void setPreferredWidth(JComponent component, int width) { component.setPreferredSize(new Dimension(width, (int) component.getPreferredSize().getHeight())); }