How to set fix size of jlabel?

You can set a fixed the size by setting the minimum, preferred and maximum size:

setMinimumSize(width, height);
setPreferredSize(width, height);
setMaximumSize(width, height);

As the Link from MadProgrammer, you need to override these methods, not using them from outside, based on the reasons mentioned in this link.


if this method not work

setMinimumSize(width, height);
setPreferredSize(width, height);
setMaximumSize(width, height);

then use it

setMinimumSize(new Dimension(width, height));
setPreferredSize(new Dimension(width, height));
setMaximumSize(new Dimension(width, height));