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

/**
 * Sets font size and style for the specified component.
 *
 * @param component/*w ww .j a va 2  s .c om*/
 *            component to modify
 * @param fontSize
 *            new font size
 * @param bold
 *            whether should set bold font or not
 * @param italic
 *            whether should set italic font or not
 * @param <C>
 *            component type
 * @return modified component
 */
public static <C extends Component> C setFontSizeAndStyle(final C component, final int fontSize,
        final boolean bold, final boolean italic) {
    final int style = bold && italic ? Font.BOLD | Font.ITALIC
            : bold ? Font.BOLD : italic ? Font.ITALIC : Font.PLAIN;
    return setFontSizeAndStyle(component, fontSize, style);
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2D;/* w ww  . jav a  2  s .  co  m*/
    g2D = (Graphics2D) g;
    FontRenderContext frc = g2D.getFontRenderContext();
    Font font1 = new Font("Courier", Font.BOLD, 24);
    String str1 = new String("Java");
    TextLayout tl = new TextLayout(str1, font1, frc);
    g2D.setColor(Color.gray);
    tl.draw(g2D, 70, 150);
}

From source file:com.uttesh.pdfngreport.util.chart.ChartStyle.java

/**
 * this method will set the style theme for pie chart.
 *
 * @see org.jfree.chart.StandardChartTheme
 * @param chart//from   www .  j a v  a  2  s.c o  m
 */
public static void theme(JFreeChart chart) {
    String fontName = "Lucida Sans";

    StandardChartTheme theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();

    theme.setTitlePaint(Color.decode("#4572a7"));
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 16)); //title
    theme.setLargeFont(new Font(fontName, Font.BOLD, 15)); //axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 11));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    theme.apply(chart);
    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
}

From source file:Text.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    g2d.setRenderingHints(rh);/*w  w  w. j  av  a2 s . c  o m*/
    Font font = new Font("New Roma", Font.BOLD, 40);
    g2d.setFont(font);
    g2d.drawString("text", 20, 30);
}

From source file:Main.java

public void paint(Graphics g) {
    Font f = g.getFont();/*  w w w .  j  a v a  2  s  . c o m*/
    String fontName = f.getName();
    String fontFamily = f.getFamily();
    int fontSize = f.getSize();
    int fontStyle = f.getStyle();

    String msg = "Family: " + fontName;
    msg += ", Font: " + fontFamily;
    msg += ", Size: " + fontSize + ", Style: ";
    if ((fontStyle & Font.BOLD) == Font.BOLD)
        msg += "Bold ";
    if ((fontStyle & Font.ITALIC) == Font.ITALIC)
        msg += "Italic ";
    if ((fontStyle & Font.PLAIN) == Font.PLAIN)
        msg += "Plain ";

    g.drawString(msg, 4, 16);
}

From source file:Main.java

public Main() {

    someComboBox.setFont(new Font("Serif", Font.BOLD, 16));
    someComboBox.setEditable(true);//w ww  . ja va  2s .c  om
    someComboBox.getEditor().getEditorComponent().setBackground(Color.YELLOW);
    ((JTextField) someComboBox.getEditor().getEditorComponent()).setBackground(Color.YELLOW);

    JTextField text = ((JTextField) editableComboBox.getEditor().getEditorComponent());
    text.setBackground(Color.YELLOW);
    JComboBox coloredArrowsCombo = editableComboBox;
    Component[] comp = coloredArrowsCombo.getComponents();
    for (int i = 0; i < comp.length; i++) {
        if (comp[i] instanceof MetalComboBoxButton) {
            MetalComboBoxButton coloredArrowsButton = (MetalComboBoxButton) comp[i];
            coloredArrowsButton.setBackground(null);
            break;
        }
    }

    non_EditableComboBox.setFont(new Font("Serif", Font.BOLD, 16));

    frame = new JFrame();
    frame.setLayout(new GridLayout(0, 1, 10, 10));
    frame.add(someComboBox);
    frame.add(editableComboBox);
    frame.add(non_EditableComboBox);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(100, 100);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder());

    add(labelTwo);//from  w w  w .j  a v  a  2s .com

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19)));
    add(labelFour);

}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder());

    add(labelTwo);/*from w ww. j a  v a 2 s.  c o  m*/

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19), Color.BLACK));
    add(labelFour);

}

From source file:Main.java

/**
 * Changes font to bold for the specified component.
 *
 * @param component// ww  w .  j a  v a 2s.c  o m
 *            component to modify
 * @param apply
 *            whether to apply font changes or not
 * @param <C>
 *            component type
 * @return modified component
 */
public static <C extends Component> C setBoldFont(final C component, final boolean apply) {
    if (apply && component != null && component.getFont() != null) {
        component.setFont(component.getFont().deriveFont(Font.BOLD));
    }
    return component;
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2D;//from  w w  w .j  ava2  s.  com
    g2D = (Graphics2D) g;

    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    FontRenderContext frc = g2D.getFontRenderContext();
    Font font1 = new Font("Courier", Font.BOLD, 24);
    String str1 = new String("Java");
    TextLayout tl = new TextLayout(str1, font1, frc);
    g2D.setColor(Color.gray);
    tl.draw(g2D, 50, 150);
}