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

public StocksTable() {
    super("Stocks Table");
    setSize(600, 300);//from  w  w w . j  a v a  2s.  com

    m_data = new StockTableData();

    m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT);
    m_title.setFont(new Font("TimesRoman", Font.BOLD, 24));
    m_title.setForeground(Color.black);
    getContentPane().add(m_title, BorderLayout.NORTH);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);

    for (int k = 0; k < StockTableData.m_columns.length; k++) {
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment);
        TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:Containers.java

public Containers() {
    this.setBackground(Color.white); // This component is white
    this.setFont(new Font("Dialog", Font.BOLD, 24));

    JPanel p1 = new JPanel();
    p1.setBackground(new Color(200, 200, 200)); // Panel1 is darker
    this.add(p1); // p1 is contained by this component
    p1.add(new JButton("#1")); // Button 1 is contained in p1

    JPanel p2 = new JPanel();
    p2.setBackground(new Color(150, 150, 150)); // p2 is darker than p2
    p1.add(p2); // p2 is contained in p1
    p2.add(new JButton("#2")); // Button 2 is contained in p2

    JPanel p3 = new JPanel();
    p3.setBackground(new Color(100, 100, 100)); // p3 is darker than p2
    p2.add(p3); // p3 is contained in p2
    p3.add(new JButton("#3")); // Button 3 is contained in p3

    JPanel p4 = new JPanel();
    p4.setBackground(new Color(150, 150, 150)); // p4 is darker than p1
    p1.add(p4); // p4 is contained in p1
    p4.add(new JButton("#4")); // Button4 is contained in p4
    p4.add(new JButton("#5")); // Button5 is also contained in p4

    this.add(new JButton("#6")); // Button6 is contained in this component
}

From source file:com.baidu.rigel.biplatform.ma.auth.resource.RandomValidateCode.java

private static Font getFont() {
    return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
}

From source file:com.jcraft.weirdx.DDXFont.java

private static synchronized Font getFont(String name, int style, int size) {
    String key = name + ',' + style + ',' + size;
    RefCount foo = (RefCount) table.get(key);
    if (foo != null) {
        // We increment the refence. 
        foo.count.incrementAndGet();//from  w w w . ja v  a2  s . c om
        return foo.font;
    }

    // Create the font and store it.
    Font f = new Font(name, style, size);
    foo = new RefCount(key, f);
    table.put(key, foo);
    return f;
}

From source file:org.jfree.chart.demo.PeriodAxisDemo3.java

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("Maximum Temperature", "Day", true, "Temperature",
            intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    PeriodAxis periodaxis = new PeriodAxis("Day");
    periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("E"),
            new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false,
            new BasicStroke(0.0F), Color.lightGray);
    aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
            new SimpleDateFormat("MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);//from w  ww. j  a v  a 2 s.  co  m
    return jfreechart;
}

From source file:StocksTable2.java

public StocksTable2() {
    super("Stocks Table");
    setSize(600, 300);//from   w  w  w  . j a  va2s.co m

    m_data = new StockTableData();

    m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT);
    m_title.setFont(new Font("TimesRoman", Font.BOLD, 24));
    m_title.setForeground(Color.black);
    getContentPane().add(m_title, BorderLayout.NORTH);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);

    for (int k = 0; k < StockTableData.m_columns.length; k++) {
        DefaultTableCellRenderer renderer = new ColoredTableCellRenderer();
        renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment);
        TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:cz.cuni.mff.ksi.jinfer.treeruledisplayer.logic.VertexFontTransformer.java

@Override
public Font transform(final Regexp<? extends AbstractNamedNode> regexp) {
    if (RegexpType.LAMBDA.equals(regexp.getType())) {
        return new Font(null, Font.BOLD, 20);
    }//from w  w w.ja va 2  s.com

    return new Font(null, Font.PLAIN, 12);
}

From source file:de.aidger.view.utils.Charts.java

/**
 * Creates a 3D pie chart./*from   w w  w  . j a  v  a2 s  .c  o  m*/
 * 
 * @param title
 *            the diagram title
 * @param dataset
 *            the dataset.
 * @param width
 *            the width of the chart as image
 * @param height
 *            the height of the chart as image
 * 
 * @return the 3D pie chart as image
 */
public static ImageIcon createPieChart3D(String title, PieDataset dataset, int width, int height) {
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);

    Font titleFont = UIManager.getFont("TitledBorder.font");

    chart.setBackgroundPaint(null);
    chart.getLegend().setBackgroundPaint(null);
    chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14));
    chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor"));
    chart.setBorderPaint(null);
    chart.getLegend().setBorder(0, 0, 0, 0);

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setForegroundAlpha(0.9f);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setNoDataMessage(_("No data to display."));
    plot.setLabelGenerator(null);
    plot.setInsets(new RectangleInsets(10, 1, 5, 1));
    plot.setBackgroundPaint(null);
    plot.setOutlineVisible(false);
    plot.setDarkerSides(true);

    return new ImageIcon(chart.createBufferedImage(width, height));
}

From source file:projectvendingmachine.AmountPieChart.java

/**
 * Creates a chart.//from  ww  w  .j  a  v  a 2 s.  co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Statistics", // chart title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}

From source file:ToolbarDemo.java

public ToolbarDemo() {
    super("Toolbars & actions");
    setSize(450, 350);//from  w w w .ja v  a2s . c om

    fonts = new Font[FontNames.length];
    for (int i = 0; i < FontNames.length; i++)
        fonts[i] = new Font(FontNames[i], Font.PLAIN, 12);

    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    updateMonitor();
    setVisible(true);
}