Java Font.getSize2D()

Syntax

Font.getSize2D() has the following syntax.

public float getSize2D()

Example

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


import java.awt.Font;
import java.awt.Graphics;
/*from w  ww .  ja v a2  s  . c  o m*/
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.getSize2D());

     

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




















Home »
  Java Tutorial »
    java.awt »




BasicStroke
BorderLayout
CardLayout
Color
Cursor
Desktop
DesktopManager
DisplayMode
EventQueue
FlowLayout
FocusTraversalPolicy
Font
FontMetrics
GradientPaint
Graphics
Graphics2D
GraphicsConfiguration
GraphicsDevice
GraphicsEnvironment
GridBagConstraints
GridBagLayout
GridLayout
Image
ItemSelectable
KeyboardFocusManager
LayoutManager
LayoutManager2
Point
Rectangle
Robot
Shape
SplashScreen
SystemColor
SystemTray
TexturePaint
TrayIcon
Toolkit
Transparency