Example usage for java.awt Font BOLD

List of usage examples for java.awt Font BOLD

Introduction

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

Prototype

int BOLD

To view the source code for java.awt Font BOLD.

Click Source Link

Document

The bold style constant.

Usage

From source file:AppletMenuBarDemo.java

public void init() {
    AppletMenuBar menubar = new AppletMenuBar();
    menubar.setForeground(Color.black);
    menubar.setHighlightColor(Color.red);
    menubar.setFont(new Font("helvetica", Font.BOLD, 12));
    this.setLayout(new BorderLayout());
    this.add(menubar, BorderLayout.NORTH);

    PopupMenu file = new PopupMenu();
    file.add("New...");
    file.add("Open...");
    file.add("Save As...");
    PopupMenu edit = new PopupMenu();
    edit.add("Cut");
    edit.add("Copy");
    edit.add("Paste");

    menubar.addMenu("File", file);
    menubar.addMenu("Edit", edit);
}

From source file:QandE.MyDemo1.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//  w  ww.java  2s  . co m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MyDemo1");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add a label with bold italic font.
    JLabel label = new JLabel("My Demo");
    frame.getContentPane().add(BorderLayout.CENTER, label);
    if (true) {
        label.setFont(label.getFont().deriveFont(Font.ITALIC | Font.BOLD));
    } else {
        //another way of doing it, but not as appropriate since 
        //setFont is faster than using HTML.
        label.setText("<html><i>My Demo</i></html>");
    }
    label.setHorizontalAlignment(JLabel.CENTER);

    //Display the window, making it a little bigger than it really needs to be.
    frame.pack();
    frame.setSize(frame.getWidth() + 100, frame.getHeight() + 50);
    frame.setVisible(true);
}

From source file:QandE.MyDemo3.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.// ww  w.  j a  va  2s . c om
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MyDemo3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add a label with bold italic font.
    JLabel label = new JLabel("My Demo");
    frame.getContentPane().add(BorderLayout.CENTER, label);
    if (true) {
        label.setFont(label.getFont().deriveFont(Font.ITALIC | Font.BOLD));
    } else {
        //another way of doing it, but not as appropriate since 
        //setFont is faster than using HTML.
        label.setText("<html><i>My Demo</i></html>");
    }
    label.setHorizontalAlignment(JLabel.CENTER);

    JButton b = new JButton("A button");
    frame.getContentPane().add(BorderLayout.PAGE_END, b);
    frame.getRootPane().setDefaultButton(b);

    //Display the window, making it a little bigger than it really needs to be.
    frame.pack();
    frame.setSize(frame.getWidth() + 100, frame.getHeight() + 50);
    frame.setVisible(true);
}

From source file:ColorGradient.java

/**
 * Get the gradient start and end colors as applet parameter values, and
 * parse them using Color.decode(). If they are malformed, use white.
 *//*  ww w .j a  va  2s  .c o m*/
public void init() {
    try {
        startColor = Color.decode(getParameter("startColor"));
        endColor = Color.decode(getParameter("endColor"));
    } catch (Exception e) {
        startColor = Color.yellow;
        endColor = Color.red;
    }
    bigFont = new Font("Helvetica", Font.BOLD, 72);
}

From source file:ClockDemo.java

/**
 * The init method is called when the browser first starts the applet. It
 * sets up the Label component and obtains a DateFormat object
 *///from w  w w .  j  a  v  a  2 s .c o  m
public void init() {
    time = new Label();
    time.setFont(new Font("helvetica", Font.BOLD, 12));
    time.setAlignment(Label.CENTER);
    setLayout(new BorderLayout());
    add(time, BorderLayout.CENTER);
    timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM);
}

From source file:com.compomics.pepshell.view.statistics.JFreeChartPanel.java

private static void setupPlot(CategoryPlot categoryPlot) {
    categoryPlot.setBackgroundPaint(Color.white);
    categoryPlot.setRangeGridlinePaint(Color.black);
    // hide the border of the sorrounding box
    categoryPlot.setOutlinePaint(Color.white);
    // get domanin and range axes
    CategoryAxis domainAxis = categoryPlot.getDomainAxis();
    ValueAxis rangeAxis = categoryPlot.getRangeAxis();
    // set label paint for axes to black
    domainAxis.setLabelPaint(Color.black);
    rangeAxis.setLabelPaint(Color.black);
    // set font for labels, both on domain and range axes
    domainAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12));
    rangeAxis.setLabelFont(new Font("Tahoma", Font.BOLD, 12));

}

From source file:D20140128.ApacheXMLGraphicsTest.EPSColorsExample.java

/**
 * Creates an EPS file. The contents are painted using a Graphics2D
 * implementation that generates an EPS file.
 *
 * @param outputFile the target file/*w  w w  . j av a 2 s  .c o  m*/
 * @throws IOException In case of an I/O error
 */
public static void generateEPSusingJava2D(File outputFile) throws IOException {
    OutputStream out = new java.io.FileOutputStream(outputFile);
    out = new java.io.BufferedOutputStream(out);
    try {
        //Instantiate the EPSDocumentGraphics2D instance
        EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        //Set up the document size
        g2d.setupDocument(out, 400, 200); //400pt x 200pt

        //Paint a bounding box
        g2d.drawRect(0, 0, 400, 200);

        g2d.setFont(new Font("sans-serif", Font.BOLD, 14));
        g2d.drawString("Color usage example:", 10, 20);
        g2d.setFont(new Font("sans-serif", Font.PLAIN, 12));
        g2d.drawString("RGB", 10, 84);
        g2d.drawString("CMYK", 60, 84);
        g2d.drawString("(Lab)", 110, 84);
        g2d.drawString("(Named)", 160, 84);

        //We're creating a few boxes all filled with some variant of the
        //"Postgelb" (postal yellow) color as used by Swiss Post.
        Color colRGB = new Color(255, 204, 0);
        g2d.setColor(colRGB);
        g2d.fillRect(10, 30, 40, 40);

        //Just convert RGB to CMYK and use that
        float[] compsRGB = colRGB.getColorComponents(null);
        DeviceCMYKColorSpace cmykCS = ColorSpaces.getDeviceCMYKColorSpace();
        float[] compsCMYK = cmykCS.fromRGB(compsRGB);
        Color colCMYK = DeviceCMYKColorSpace.createCMYKColor(compsCMYK);
        g2d.setColor(colCMYK);
        g2d.fillRect(60, 30, 40, 40);

        //Try CIELab (not implemented, yet)
        CIELabColorSpace d50 = ColorSpaces.getCIELabColorSpaceD50();
        Color colLab = d50.toColor(83.25f, 16.45f, 96.89f, 1.0f);
        g2d.setColor(colLab);
        g2d.fillRect(110, 30, 40, 40);

        //Try named color (Separation, not implemented, yet)
        float[] c1xyz = d50.toCIEXYZNative(83.25f, 16.45f, 96.89f);
        NamedColorSpace postgelb = new NamedColorSpace("Postgelb", c1xyz);
        Color colNamed = new Color(postgelb, new float[] { 1.0f }, 1.0f);
        g2d.setColor(colNamed);
        g2d.fillRect(160, 30, 40, 40);

        //Cleanup
        g2d.finish();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.ouc.cpss.view.ProfitChartBuilder.java

public static JFreeChart createJFreeChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createLineChart("?", "", "?",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    // ?/* w  w  w .ja va2  s . c om*/
    LegendTitle legendTitle = chart.getLegend(0);
    // 
    legendTitle.setItemFont(new Font("", Font.BOLD, 18));
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    // ?
    org.jfree.chart.axis.CategoryAxis categoryAxis = plot.getDomainAxis();
    // 
    categoryAxis.setLabelFont(new Font("", Font.BOLD, 18));

    // 
    categoryAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    // ?
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    // 
    numberAxis.setLabelFont(new Font("", Font.BOLD, 14));

    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());//

    CategoryItemRenderer xylineandshaperenderer = plot.getRenderer();
    xylineandshaperenderer.setBaseItemLabelsVisible(true);
    xylineandshaperenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.BASELINE_RIGHT));
    xylineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    return chart;
}

From source file:com.tencent.wstt.apt.chart.CPURealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset,
            true, true, false);/*from  w w w. j a v  a  2 s  . c  o  m*/

    //??
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    return chart;
}

From source file:Main.java

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
        int column) {
    JTextField editor = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column);

    if (value != null)
        editor.setText(value.toString());
    if (column == 0) {
        editor.setHorizontalAlignment(SwingConstants.CENTER);
        editor.setFont(new Font("Serif", Font.BOLD, 14));
    } else {//  w  w  w  .j  a  va  2 s.  c o  m
        editor.setHorizontalAlignment(SwingConstants.RIGHT);
        editor.setFont(new Font("Serif", Font.ITALIC, 12));
    }
    return editor;
}