Example usage for java.awt Font PLAIN

List of usage examples for java.awt Font PLAIN

Introduction

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

Prototype

int PLAIN

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

Click Source Link

Document

The plain style constant.

Usage

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Font font = new Font("Serif", Font.PLAIN, 40);

    AttributedString as1 = new AttributedString("1234567890");
    as1.addAttribute(TextAttribute.FONT, font);
    g2d.drawString(as1.getIterator(), 15, 60);
}

From source file:HelloInJapanese.java

public HelloInJapanese(String characters) {
    Font theFont = new Font("Bitstream Cyberbit", Font.PLAIN, 20);
    JTextArea area = new JTextArea(characters, 2, 30);
    area.setFont(theFont);/*w  ww.  jav a  2  s. co  m*/
    area.setLineWrap(true);
    JScrollPane scrollpane = new JScrollPane(area);
    add(scrollpane);
}

From source file:TextLayoutOne.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

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

    String s = "Java Source and Support.";
    Font font = new Font("Serif", Font.PLAIN, 32);

    TextLayout textLayout = new TextLayout(s, font, g2.getFontRenderContext());
    textLayout.draw(g2, 40, 80);//from w w w.  j av a2  s . c  om
}

From source file:Main.java

public Main() {
    setSize(300, 150);/*ww  w.  j a  va2  s . c  o m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    add(b);
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            b.setFont(new Font("Dialog", Font.PLAIN, ++size));
            b.revalidate();
        }
    });
    setVisible(true);
}

From source file:HorizontallyCenteredText.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

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

    g2.setFont(new Font("Serif", Font.PLAIN, 48));

    paintHorizontallyCenteredText(g2, "Java Source", 200, 75);
    paintHorizontallyCenteredText(g2, "and", 200, 125);
    paintHorizontallyCenteredText(g2, "Support", 200, 175);
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();

    GlyphVector gv = font.createGlyphVector(frc, s);
    g2.drawGlyphVector(gv, 40, 60);/*ww w .  j  a va  2  s.  c  o m*/
}

From source file:DrawStringDemo.java

public void paint(Graphics g) {
    Graphics2D graphics2D = (Graphics2D) g;
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font font = new Font("LucidaSans", Font.PLAIN, 40);
    graphics2D.setFont(font);//  w  ww. j a v a 2  s  .  c  o m
    graphics2D.drawString(message, 50, 75);
}

From source file:Main.java

/**
 * Sets font style for the specified component.
 *
 * @param component//from w  w  w  .  ja  va  2s  . com
 *            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:SimpleFont.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

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

    String s = "Java Source and Support";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();

    GlyphVector gv = font.createGlyphVector(frc, s);
    g2.drawGlyphVector(gv, 40, 60);/*from  w ww  .  j a va2 s . c  o  m*/
}

From source file:IteratorUnderStrike.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String s = "\"www.java2s.com\" is great.";

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font plainFont = new Font("Times New Roman", Font.PLAIN, 24);

    AttributedString as = new AttributedString(s);
    as.addAttribute(TextAttribute.FONT, plainFont);
    as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 1, 15);
    as.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 18, 25);

    g2.drawString(as.getIterator(), 24, 70);
}