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:Main.java

public static Font getFontBold(int size) {
    return new Font("Dialog", Font.BOLD, size);
}

From source file:Main.java

/**
 * Sets the bold font./*from   w  w w. j a  v a 2  s  .c o m*/
 *
 * @param comp
 *            the new bold font
 */
public static void setBoldFont(final Component comp) {
    comp.setFont(new Font("Tahoma", Font.BOLD, 10));
}

From source file:DataCharts.LineGraph.java

public static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Customers by Month", "Months", "Customers", dataset);

    String fontName = "SansSerif";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    chart.addSubtitle(new TextTitle(" ", new Font(fontName, Font.PLAIN, 14)));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(false);//www  .  ja  va  2 s  .co  m
    plot.setRangePannable(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setDrawSeriesLineAsPath(false);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);

    }
    return chart;

}

From source file:Main.java

public static Font getFont(String name) {
    Font font = null;/* w  w w.  jav  a 2s  . co m*/
    if (cache != null) {
        if ((font = cache.get(name)) != null) {
            return font;
        }
    }
    String fName = "/fonts/" + name;
    try {
        InputStream is = Main.class.getResourceAsStream(fName);
        font = Font.createFont(Font.TRUETYPE_FONT, is);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(fName + " not loaded.  Using serif font.");
        font = new Font("serif", Font.PLAIN, 24);
    }
    return font;
}

From source file:MyCanvas.java

public void paint(Graphics g) {
    Font courier = new Font("Courier", Font.PLAIN, 12);
    Font system = new Font("System", Font.BOLD, 16);
    Font helvetica = new Font("Helvetica", Font.BOLD, 18);

    g.setFont(courier);//from   w w  w .  j a va  2s .  co  m
    g.drawString("Courier", 10, 30);
    g.setFont(system);
    g.drawString("System", 10, 70);
    g.setFont(helvetica);
    g.drawString("Helvetica", 10, 90);
}

From source file:Main.java

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

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

    g.drawString("www.java2s.com", 10, 20);
}

From source file:Main.java

public Main() {
    setFont(new Font("TimesRoman", Font.BOLD | Font.ITALIC, 48));
    setSize(225, 175);
}

From source file:MainClass.java

public void paint(Graphics g) {
    Font f = new Font("Serif", Font.PLAIN, 12);
    g.setFont(f);//from   w  ww. ja  va  2s  . c  om
    g.drawString("Serif - PLAIN - 12", 10, 30);

    f = new Font("Sanserif", Font.ITALIC, 10);
    g.setFont(f);
    g.drawString("Sanserif - ITALIC - 10", 10, 60);

    f = new Font("Monospaced", Font.BOLD | Font.ITALIC, 14);
    g.setFont(f);
    g.drawString("Monospaced - BOLD and ITALIC - 14", 10, 90);

    f = new Font("Dialog", Font.PLAIN, 12);
    g.setFont(f);
    g.drawString("Dialog - PLAIN - 12", 10, 120);

    f = new Font("DialogInput", Font.BOLD + Font.ITALIC, 10);
    g.setFont(f);
    g.drawString("DialogInput - BOLD and ITALIC - 10", 10, 150);
}

From source file:Main.java

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

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

    String s = "www.java2s.com";

    g.setColor(Color.black);/*from  ww w .j ava 2 s .c  o  m*/
    g.drawString(s, 30, 30);
}

From source file:Main.java

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

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

    String s = "www.java2s.com";

    g.setColor(Color.black);/*  www  . j a v  a  2 s. co  m*/
    g.drawString(s, 30, 30);
}