We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
JLabel label = new JLabel("I'm bold");
Font font = new Font("Courier", Font.BOLD,12);
label.setFont(font);
You can change the bold attribute after the creation.
Font f = label.getFont();
// bold
label.setFont(f.deriveFont(f.getStyle() | Font.BOLD));
// unbold
label.setFont(f.deriveFont(f.getStyle() & ~Font.BOLD));
// toggle bold
label.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD));