Java Utililty Methods JComponent Size

List of utility methods to do JComponent Size

Description

The list of methods to do JComponent Size are organized into topic(s).

Method

voidsetMinimumSize(JComponent component, int numChars)
set Minimum Size
int width = calculateCharWidth(component, numChars);
if (width > 0) {
    Dimension current = component.getPreferredSize();
    Dimension d = new Dimension(width, current.height);
    component.setPreferredSize(d);
DimensionsetPreferredSize(JComponent comp, int height, int width)
set Preferred Size
Dimension result = null;
Dimension preferredSize = comp.getPreferredSize();
if (height != LEAVE)
    preferredSize.height = height;
if (width != LEAVE)
    preferredSize.width = width;
comp.setPreferredSize(preferredSize);
result = preferredSize;
...
voidsetSize(Dimension size, JComponent[] components)
set Size
for (JComponent component : components) {
    component.setSize(size);
voidsetSize(final Component component, final int width, final int height)
set Size
if (component != null && width >= 0 && height >= 0) {
    runInEDT(() -> {
        component.setMaximumSize(new Dimension(width, height));
        component.setMinimumSize(new Dimension(width, height));
        component.setPreferredSize(new Dimension(width, height));
        component.setSize(new Dimension(width, height));
    });
voidsetSize(JComponent c, int w)
set Size
Dimension d = new Dimension(w, c.getPreferredSize().height);
c.setMinimumSize(d);
c.setPreferredSize(d);
c.setMaximumSize(d);
JComponentsetSize(JComponent comp, int w, int h)
Set the size and preferred size of the component and return it
comp.setSize(w, h);
comp.setPreferredSize(new Dimension(w, h));
return comp;
voidsetSize(JComponent componenet, Dimension dimension)
set Size
componenet.setMinimumSize(dimension);
componenet.setMaximumSize(dimension);
componenet.setPreferredSize(dimension);
voidsetSize(JComponent componenet, Dimension dimension)
setButtonOk
componenet.setMinimumSize(dimension);
componenet.setMaximumSize(dimension);
componenet.setPreferredSize(dimension);
voidsetSize(JComponent component, int width, int height)
set Size
Dimension textPanelSize = new Dimension(width, height);
component.setSize(textPanelSize);
component.setPreferredSize(textPanelSize);
component.setMaximumSize(textPanelSize);
component.setMinimumSize(textPanelSize);
voidsetSize(JComponent conponent, int width, int height)
set Size
conponent.setMinimumSize(new Dimension(width, height));
conponent.setPreferredSize(new Dimension(width, height));