Example usage for java.awt Font Font

List of usage examples for java.awt Font Font

Introduction

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

Prototype

private Font(String name, int style, float sizePts) 

Source Link

Usage

From source file:DrawStringI18N.java

public void paint(Graphics g) {
    Graphics2D graphics2D = (Graphics2D) g;
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    graphics2D.setFont(new Font("LucidaSans", Font.PLAIN, 40));
    graphics2D.drawString("\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD", 50, 75);
}

From source file:MainClass.java

public void init() {
    f = new Font("Dialog", Font.PLAIN, 12);
    msg = "Dialog";
    setFont(f);//from   w w  w . ja  v a 2 s. c om
    addMouseListener(new MyMouseAdapter(this));
}

From source file:MainClass.java

public void paint(Graphics g) {
    int fontSize = 20;

    g.setFont(new Font("TimesRoman", Font.PLAIN, fontSize));

    FontMetrics fm = g.getFontMetrics();

    String s = "www.java2s.com";

    int stringWidth = fm.stringWidth(s);

    int w = 200;//  w  w  w.ja v a2s .c  om
    int h = 200;

    int x = (w - stringWidth) / 2;
    int baseline = fm.getMaxAscent() + (h - (fm.getAscent() + fm.getMaxDecent())) / 2;
    int ascent = fm.getMaxAscent();
    int descent = fm.getMaxDecent();
    int fontHeight = fm.getMaxAscent() + fm.getMaxDecent();

    g.setColor(Color.white);
    g.fillRect(x, baseline - ascent, stringWidth, fontHeight);

    g.setColor(Color.gray);
    g.drawLine(x, baseline, x + stringWidth, baseline);

    g.setColor(Color.red);
    g.drawLine(x, baseline + descent, x + stringWidth, baseline + descent);

    g.setColor(Color.blue);
    g.drawLine(x, baseline - ascent, x + stringWidth, baseline - ascent);
    g.setColor(Color.black);
    g.drawString(s, x, baseline);
}

From source file:Main.java

License:asdf

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.draw(getTextShape(g2d, "asdf", new Font("", 1, 30)));
}

From source file:BasicShapes.java

License:asdf

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    getTextShape(g2d, "asdf", new Font("", 1, 1));

}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font font = new Font("Serif", Font.PLAIN, 96);
    g2.setFont(font);//from  ww w. j  a va2s . c om

    g2.drawString("java2s.com", 40, 120);
}

From source file:TrueTypeJokerman.java

public TrueTypeJokerman() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();//  ww  w .  java 2s. c o  m

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);

    getContentPane().add(textLabel);
    setVisible(true);
}

From source file:Main.java

public void paint(Graphics g) {
    g.setFont(new Font("SansSerif", Font.BOLD, 12));
    FontMetrics fm = g.getFontMetrics();
    g.drawString("Current font: " + g.getFont(), 10, 40);
    g.drawString("Ascent: " + fm.getAscent(), 10, 55);
    g.drawString("Descent: " + fm.getDescent(), 10, 70);
    g.drawString("Height: " + fm.getHeight(), 10, 85);
    g.drawString("Leading: " + fm.getLeading(), 10, 100);

    Font font = new Font("Serif", Font.ITALIC, 14);
    fm = g.getFontMetrics(font);//from www  .  j  av  a2s. c o  m
    g.setFont(font);
    g.drawString("Current font: " + font, 10, 130);
    g.drawString("Ascent: " + fm.getAscent(), 10, 145);
    g.drawString("Descent: " + fm.getDescent(), 10, 160);
    g.drawString("Height: " + fm.getHeight(), 10, 175);
    g.drawString("Leading: " + fm.getLeading(), 10, 190);
}

From source file:DrawSimpleText.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font font = new Font("Serif", Font.PLAIN, 96);
    g2.setFont(font);// w  w  w .  j a  v  a 2 s.c  om

    g2.drawString("Java Source and Support", 40, 120);
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeSetup.java

public static void setup() {
    StandardChartTheme theme = new StandardChartTheme("webapp");
    theme.setSmallFont(new Font("Arial", Font.PLAIN, 10));
    theme.setRegularFont(new Font("Arial", Font.PLAIN, 12));
    theme.setLargeFont(new Font("Arial", Font.PLAIN, 14));
    theme.setExtraLargeFont(new Font("Arial", Font.PLAIN, 20));

    ChartFactory.setChartTheme(theme);/*from   w ww  .j av  a  2 s  . com*/
}