List of usage examples for javax.swing JTextField getFontMetrics
public FontMetrics getFontMetrics(Font font)
FontMetrics
for the specified Font
. 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*/ }