Example usage for java.awt FontMetrics bytesWidth

List of usage examples for java.awt FontMetrics bytesWidth

Introduction

In this page you can find the example usage for java.awt FontMetrics bytesWidth.

Prototype

@SuppressWarnings("deprecation")
public int bytesWidth(byte[] data, int off, int len) 

Source Link

Document

Returns the total advance width for showing the specified array of bytes in this Font .

Usage

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 ww  . j av a 2 s . c  o m
    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);

}