Example usage for javax.swing JTextField getFontMetrics

List of usage examples for javax.swing JTextField getFontMetrics

Introduction

In this page you can find the example usage for javax.swing JTextField getFontMetrics.

Prototype

public FontMetrics getFontMetrics(Font font) 

Source Link

Document

Gets the FontMetrics for the specified Font.

Usage

From source file:Main.java

public static JTextField createStandardTextField() {
    JTextField tf = new JTextField();
    FontMetrics fm = tf.getFontMetrics(tf.getFont());
    //   tf.setPreferredSize(new Dimension(150, fm.getHeight()));
    return tf;/*from   ww  w  .  ja  va2s  . co m*/
}