To change the font size of a JLabel
in Java, you can use the setFont
method of the JLabel
class and pass it a new Font
object with the desired size.
Here's an example of how you might do this:
import java.awt.Font; import javax.swing.JLabel; public class Main { public static void main(String[] args) { JLabel label = new JLabel("Hello, World!"); label.setFont(new Font(label.getFont().getName(), label.getFont().getStyle(), 24)); } }Swww:ecruo.lautturi.com
In this example, the setFont
method is used to set the font of the JLabel
to a new font with the same name and style as the original font, but with a size of 24 points.
You can adjust the font size as desired by changing the third argument to the Font
constructor.