Java Swing Tutorial - Java Font.isBold()








Syntax

Font.isBold() has the following syntax.

public boolean isBold()

Example

In the following code shows how to use Font.isBold() method.

import java.awt.Font;
import java.awt.Graphics;
//w  w w. ja  v  a 2 s .  c om
import javax.swing.JFrame;

public class Main extends JFrame {

  public static void main(String[] a) {
    Main f = new Main();
    f.setSize(300, 300);
    f.setVisible(true);
  }

  public void paint(Graphics g) {
    Font f = g.getFont();
    
    System.out.println(f.isBold());

     

    g.drawString("java2s.com", 4, 16);
  }
}