Example usage for javax.swing JFrame getFont

List of usage examples for javax.swing JFrame getFont

Introduction

In this page you can find the example usage for javax.swing JFrame getFont.

Prototype

@Transient
public Font getFont() 

Source Link

Document

Gets the font of this component.

Usage

From source file:GettingFontMetrics.java

public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FontMetrics metrics = f.getFontMetrics(f.getFont());

    f.setSize(300, 200);/*from  w ww  . ja  v  a2  s.  c  o m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.setSize(300, 200);//from w  w  w  . ja  v  a2  s  .c o  m
    f.setVisible(true);

    FontMetrics metrics = f.getFontMetrics(f.getFont());

    int widthX = metrics.charsWidth(new char[] { 'a', 'b' }, 1, 2);

    System.out.println(widthX);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.setSize(300, 200);/*w  w w .  j av a2 s  . c om*/
    f.setVisible(true);

    FontMetrics metrics = f.getFontMetrics(f.getFont());

    int widthX = metrics.charWidth((int) 'C');

    System.out.println(widthX);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.setSize(300, 200);//from w w  w  .  ja va 2 s  .c o  m
    f.setVisible(true);

    FontMetrics metrics = f.getFontMetrics(f.getFont());

    int widthX = metrics.charWidth('X');

    System.out.println(widthX);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.setSize(300, 200);//from w  w w .  j a  v a 2  s.c om
    f.setVisible(true);

    FontMetrics metrics = f.getFontMetrics(f.getFont());

    int widthX = metrics.bytesWidth(new byte[] { 66, 67, 68, 69 }, 1, 2);

    System.out.println(widthX);

}