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

public static void italicBoldLabel(JLabel label) {
    label.setFont(label.getFont().deriveFont(Font.BOLD + Font.ITALIC));
}

From source file:Main.java

/**
 * Displays a message dialog with given information.
 *///from w  w w  .  j  a  v a 2  s  . co  m
public static void showInformationDialog(Component component, String message) {
    final JPanel panel = new JPanel(new BorderLayout(5, 5));

    final JLabel messageLabel = new JLabel(message);
    messageLabel.setFont(new Font("Dialog", Font.BOLD, messageLabel.getFont().getSize()));

    panel.add(messageLabel, BorderLayout.CENTER);

    // Adjust stack trace dimensions
    final Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    screenDimension.setSize(screenDimension.getWidth() * 0.7, screenDimension.getHeight() * 0.7);
    final Dimension maxStackTraceDimension = new Dimension(500, 500);
    maxStackTraceDimension.setSize(Math.min(maxStackTraceDimension.getWidth(), screenDimension.getWidth()),
            Math.min(maxStackTraceDimension.getHeight(), screenDimension.getHeight()));

    JOptionPane.showMessageDialog(component, panel, "Information", JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

public static <T extends JComponent> T strongFont(T comp) {
    comp.setFont(comp.getFont().deriveFont(Font.BOLD, 12f));
    return comp;
}

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   ww  w . ja  v  a 2s  . 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:Main.java

/**
 * Apply bold font to a Jlabel./*from w w w .  j  a v  a 2  s .  co  m*/
 * @param label
 */
public static void bold(final JLabel label) {
    final Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() ^ Font.BOLD));
}

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);/*  ww w .  ja v  a 2s  .c o  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

/**
 * Modifica fontul de la un label si il face bold
 * @param component/*from   w  w  w  .  ja  va2  s  .  c o m*/
 */
public static void setFontBold(Component component) {
    Font oldFont = component.getFont();
    if (oldFont != null)
        component.setFont(oldFont.deriveFont(Font.BOLD));
}

From source file:Main.java

public static String getNiceFontName(Font font) {
    if (font == null)
        return "";
    StringBuilder buf = new StringBuilder();
    buf.append(font.getName());/*from w w w .ja  v a2  s  .  c o  m*/
    buf.append(", ");
    switch (font.getStyle()) {
    case Font.BOLD:
        buf.append("bold");
        break;
    case Font.ITALIC:
        buf.append("italic");
        break;
    case Font.PLAIN:
        buf.append("plain");
        break;
    }
    buf.append(", ");
    buf.append(font.getSize());
    return buf.toString();
}

From source file:Main.java

/**
 * Gets the text width.//from   w  ww . j  ava 2 s . c o  m
 *
 * @param text
 *            the text
 * @param bold
 *            the bold
 * @return the text width
 */
public static int getTextWidth(final String text, final boolean bold) {
    Font font = UIManager.getFont("Label.font");
    if (bold) {
        font = font.deriveFont(Font.BOLD);
    }
    return getTextWidth(text, font);
}