Java Utililty Methods JComponent Width

List of utility methods to do JComponent Width

Description

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

Method

voidsetPreferredWidth(JComponent comp, int width)
Sets preferred width of the component.
Dimension size = comp.getPreferredSize();
size.width = width;
comp.setPreferredSize(size);
voidsetPreferredWidth(JComponent comp, int width)
Set the preferred width on a component
int height = comp.getPreferredSize().height;
if (!checkHeight(height)) {
    height = 24;
comp.setPreferredSize(new Dimension(width, height));
voidsetPreferredWidth(JComponent component, int width)
set Preferred Width
Dimension d = component.getPreferredSize();
d.width = width;
component.setPreferredSize(d);
voidsetPreferredWidth(JComponent component, int width)
set Preferred Width
int height = component.getPreferredSize().height;
component.setPreferredSize(new Dimension(width, height));
voidsetPreferredWidth(JComponent component, int width)
set Preferred Width
component.setPreferredSize(getPreferredSize(component, width));
voidsetPrefferedWidth(JComponent c, int w)
set Preffered Width
c.setPreferredSize(new Dimension(w, (int) c.getPreferredSize().getHeight()));
JComponentsetZeroWidth(JComponent comp)
Sets the preferred width of a component to zero (0).
Dimension dims = comp.getPreferredSize();
dims.width = 0;
comp.setPreferredSize(dims);
return comp;
voidtoFixedDim(JComponent c, int width, int height)
to Fixed Dim
Dimension dimension = new Dimension(width, height);
c.setPreferredSize(dimension);
c.setMaximumSize(dimension);
c.setMinimumSize(dimension);