private static void forceSize(Component c, int width, int height) { Dimension d = new Dimension(width, height); c.setSize(d); c.setMinimumSize(d); c.setMaximumSize(d); c.setPreferredSize(d); }
private void forceSize(Component c, int width, int height) { c.setSize(width, height); Dimension d = new Dimension(width, height); c.setMinimumSize(d); c.setMaximumSize(d); c.setPreferredSize(d); } }
private void forceSize(Component c, int width, int height) { c.setSize(width, height); Dimension d = new Dimension(width, height); c.setMinimumSize(d); c.setMaximumSize(d); c.setPreferredSize(d); }
private void setGUISize() { Font font = GUISizeHelper.menuFont; mageToolbar.setFont(font); int newHeight = font.getSize() + 6; Dimension mageToolbarDimension = mageToolbar.getPreferredSize(); mageToolbarDimension.height = newHeight + 6; mageToolbar.setMinimumSize(mageToolbarDimension); mageToolbar.setMaximumSize(mageToolbarDimension); mageToolbar.setPreferredSize(mageToolbarDimension); for (Component component : mageToolbar.getComponents()) { if (component instanceof JButton || component instanceof JLabel || component instanceof JToggleButton) { component.setFont(font); Dimension d = component.getPreferredSize(); d.height = newHeight; component.setMinimumSize(d); component.setMaximumSize(d); } if (component instanceof javax.swing.JToolBar.Separator) { Dimension d = component.getPreferredSize(); d.height = newHeight; component.setMinimumSize(d); component.setMaximumSize(d); } } balloonTip.setFont(GUISizeHelper.balloonTooltipFont); addTooltipContainer(); } }
setTitle("Custom Component Test / BoxLayout"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setMaximumSize(getMinimumSize()); setMinimumSize(getMinimumSize()); setPreferredSize(getPreferredSize());
/** * @see AbstractComponentProperty#setPropertyValueToComponent(Object) */ @Override protected void setPropertyValueToComponent(Dimension value) { component.setMaximumSize(value); } }
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); c.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); panel.removeAll(); panel.add(c); return c;
public static void setPreferredAsSize(Component comp) { Dimension pref = comp.getPreferredSize(); comp.setMaximumSize(pref); comp.setMinimumSize(pref); }
private static void setOptimalSizeForComboBox(Component component) { component.setMinimumSize(new Dimension(GUIConstants.POLICY_PANEL_PREFERRED_COMBO_BOX_WIDTH, GUIConstants.PREFERRED_POLICY_WINDOW_ELEMENT_HEIGHT)); component.setPreferredSize(new Dimension(GUIConstants.POLICY_PANEL_PREFERRED_COMBO_BOX_WIDTH, GUIConstants.PREFERRED_POLICY_WINDOW_ELEMENT_HEIGHT)); component.setMaximumSize(new Dimension(GUIConstants.POLICY_PANEL_PREFERRED_COMBO_BOX_WIDTH, GUIConstants.PREFERRED_POLICY_WINDOW_ELEMENT_HEIGHT)); }
private void heightConstrain(Component component) { Dimension d = new Dimension(component.getMaximumSize().width, component.getMinimumSize().height); component.setMaximumSize(d); }
private void heightConstrain(Component component) { Dimension d = new Dimension(component.getMaximumSize().width, component.getMinimumSize().height); component.setMaximumSize(d); }
private void setSameButtonWidth(JPanel buttonContainer) { //Set this size to all buttons for(Component component : buttonContainer.getComponents()) { if(component instanceof JButton) { component.setMaximumSize(new Dimension(Short.MAX_VALUE, component.getMaximumSize().height)); } } }
package CustomComponents; import java.awt.Container; import java.awt.Dimension; public class CSize { public static void setDefiniteSize(Container c, int h, int w) { Dimension k = new Dimension (h, w); c.setMaximumSize(k); c.setMinimumSize(k); c.setPreferredSize(k); } }
private static void setFixedSize(Component component, Dimension dimension) { component.setPreferredSize(dimension); component.setMinimumSize(dimension); component.setMaximumSize(dimension); }
/** * Sets exact size of a component * * @param c * @param width * @param height */ private void forceExactSize(Component c, int width, int height) { c.setMinimumSize(new Dimension(width, height)); c.setMaximumSize(new Dimension(width, height)); c.setPreferredSize(new Dimension(width, height)); c.setSize(width, height); }
private void adjustSizes(Component component, IFormatter formatter, Object templateValue, int extraWidth) { int preferredWidth = computePixelWidth(component, getFormatLength( formatter, templateValue)) + extraWidth; Dimension size = new Dimension(preferredWidth, component.getPreferredSize().height); component.setMinimumSize(size); component.setPreferredSize(size); component.setMaximumSize(size); }
public static void setAllSizes(Component comp, Dimension dim) { comp.setPreferredSize(dim); comp.setMaximumSize(dim); comp.setMinimumSize(dim); comp.setSize(dim); }
@ScriptFunction(jsDoc = CLEAR_JSDOC) @Override public void clear() { for (java.awt.Component comp : super.getComponents()) { comp.removePropertyChangeListener(resizer); comp.setMaximumSize(null); comp.setPreferredSize(null); } super.removeAll(); }
public static void setFixedSize(Component component, Dimension dimension) { component.setSize(dimension); component.setPreferredSize(dimension); component.setMaximumSize(dimension); component.setMinimumSize(dimension); }
private void fillRightPart(Component comp) { mainContentSplitPane.setRightComponent(comp); mainContentSplitPane.getLeftComponent().setMinimumSize(new Dimension(0, 0)); mainContentSplitPane.getLeftComponent().setMaximumSize(new Dimension(0, 0)); mainContentSplitPane.getRightComponent().setMinimumSize(new Dimension(250, 0)); frmCdboxdSceneEditor.validate(); canvasPanel.getComponent(0).requestFocus();//focus the main canvas }