How to change the size of the font of a JLabel to take the maximum size
I have a JLabel in a Container. The defaut size of the font is very small. I would like that the text of the JLabel to take the maximum size. How can I do that? coobird Not the most pretty code, but the following will pick an appropriate font size for a JLabel called label such that the text inside will fit the interior as much as possible without overflowing the label: Font labelFont = label.getFont(); String labelText = label.getText(); int stringWidth = label.getFontMetrics(labelFont).stringWidth(labelText); int componentWidth = label.getWidth(); // Find out how much the font can grow in