Example usage for java.awt Font ITALIC

List of usage examples for java.awt Font ITALIC

Introduction

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

Prototype

int ITALIC

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

Click Source Link

Document

The italicized style constant.

Usage

From source file:Main.java

private static JPanel createLogin() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    JLabel label = new JLabel("login panel.");
    label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f));
    label.setAlignmentX(0.5f);/*from   ww w  .  j av  a 2  s  .  c  o m*/
    label.setBorder(new EmptyBorder(0, 20, 0, 20));
    p.add(Box.createVerticalStrut(36));
    p.add(label);
    p.add(Box.createVerticalStrut(144));
    return p;
}

From source file:Main.java

public static String getNiceFontName(Font font) {
    if (font == null)
        return "";
    StringBuilder buf = new StringBuilder();
    buf.append(font.getName());/*from www .  j av a 2  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

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

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);/* w w  w  .  ja  v  a 2 s.c o  m*/
    g.drawString(s, 30, 30);
}

From source file:MainClass.java

public void paint(Graphics g) {
    Font f = new Font("Serif", Font.PLAIN, 12);
    g.setFont(f);/*from w  w w . ja v a 2s . c o m*/
    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:ShadowText.java

public void paint(Graphics g) {
    String text = "Hello World";
    int x = 10;//w  w w .  j  a  v  a2s  . c  o  m
    int y = 100;

    Font font = new Font("Georgia", Font.ITALIC, 50);
    Graphics2D g1 = (Graphics2D) g;

    TextLayout textLayout = new TextLayout(text, font, g1.getFontRenderContext());
    g1.setPaint(new Color(150, 150, 150));
    textLayout.draw(g1, x + 3, y + 3);

    g1.setPaint(Color.BLACK);
    textLayout.draw(g1, x, y);
}

From source file:Main.java

/**
 * Sets font style for the specified component.
 *
 * @param component//  w  w  w .j  a v a  2s .  c o  m
 *            component to modify
 * @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 setFontStyle(final C component, final boolean bold,
        final boolean italic) {
    final int style = bold && italic ? Font.BOLD | Font.ITALIC
            : bold ? Font.BOLD : italic ? Font.ITALIC : Font.PLAIN;
    return setFontStyle(component, style);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Some label text");
    label.setBorder(BorderFactory.createLineBorder(Color.green));
    label.setFont(new Font("Serif", Font.ITALIC, 16));

    getContentPane().add(label);/*from  w w  w  .j  a  v a  2s . c o m*/
    pack();
    setVisible(true);
}

From source file:FontPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Font f = new Font("SansSerif", Font.BOLD, 14);
    Font fi = new Font("SansSerif", Font.BOLD + Font.ITALIC, 14);
    FontMetrics fm = g.getFontMetrics(f);
    FontMetrics fim = g.getFontMetrics(fi);

    String s1 = "Java ";
    String s2 = "Source and Support";
    String s3 = " at www.java2s.com";
    int width1 = fm.stringWidth(s1);
    int width2 = fim.stringWidth(s2);
    int width3 = fm.stringWidth(s3);

    Dimension d = getSize();//from  ww w .  ja  v  a2 s .com
    int cx = (d.width - width1 - width2 - width3) / 2;
    int cy = (d.height - fm.getHeight()) / 2 + fm.getAscent();

    g.setFont(f);
    g.drawString(s1, cx, cy);
    cx += width1;
    g.setFont(fi);
    g.drawString(s2, cx, cy);
    cx += width2;
    g.setFont(f);
    g.drawString(s3, cx, cy);
}

From source file:metrics.java

License:asdf

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