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

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font font = new Font("Serif", Font.PLAIN, 96);
    g2.setFont(font);//w  ww .  j a v  a  2  s.  co  m

    g2.drawString("jade", 40, 120);
}

From source file:Main.java

public Main() {
    super();//from   w ww  .  j a v  a  2s  . c o m
    setSize(450, 350);
    for (int k = 0; k < FontName.length; k++)
        fonts[k] = new Font(FontName[k], Font.PLAIN, 12);

    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setVisible(true);
}

From source file:TextRendering.java

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

    Dimension d = getSize();//www.  ja  v  a2s .  com
    AffineTransform ct = AffineTransform.getTranslateInstance(d.width / 2, d.height * 3 / 4);
    g2.transform(ct);

    String s = "www.java2s.com";
    Font f = new Font("Serif", Font.PLAIN, 128);
    g2.setFont(f);

    int count = 6;
    for (int i = 1; i <= count; i++) {
        AffineTransform oldTransform = g2.getTransform();

        float ratio = (float) i / (float) count;
        g2.transform(AffineTransform.getRotateInstance(Math.PI * (ratio - 1.0f)));
        float alpha = ((i == count) ? 1.0f : ratio / 3);
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        g2.drawString(s, 0, 0);

        g2.setTransform(oldTransform);
    }
}

From source file:TextLayoutLineBreakerMeasurer.java

public void paint(Graphics g) {
    Graphics2D graphics2D = (Graphics2D) g;
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font font = new Font("LucidaSans", Font.PLAIN, 14);
    AttributedString messageAS = new AttributedString(m);
    messageAS.addAttribute(TextAttribute.FONT, font);
    AttributedCharacterIterator messageIterator = messageAS.getIterator();
    FontRenderContext messageFRC = graphics2D.getFontRenderContext();
    LineBreakMeasurer messageLBM = new LineBreakMeasurer(messageIterator, messageFRC);

    Insets insets = getInsets();//from w w  w.ja v  a2 s  . co m
    float wrappingWidth = getSize().width - insets.left - insets.right;
    float x = insets.left;
    float y = insets.top;

    while (messageLBM.getPosition() < messageIterator.getEndIndex()) {
        TextLayout textLayout = messageLBM.nextLayout(wrappingWidth);
        y += textLayout.getAscent();
        textLayout.draw(graphics2D, x, y);
        y += textLayout.getDescent() + textLayout.getLeading();
        x = insets.left;
    }
}

From source file:GridSizeTest.java

public GridSizeTest() {
    Container pane = getContentPane();
    pane.setLayout(new GridLayout(2, 2));
    JButton button = new JButton("First");
    pane.add(button);/*from  ww  w  .  j  a  v a2 s .c  o  m*/
    button = new JButton("Second with a very long name");
    pane.add(button);
    button = new JButton("Hi");
    button.setFont(new Font("Courier", Font.PLAIN, 36));
    pane.add(button);
    button = new JButton("There");
    pane.add(button);
}

From source file:MainClass.java

public MainClass() {
    NumberFormat nf = NumberFormat.getInstance();
    if (nf instanceof DecimalFormat) {
        DecimalFormat df = (DecimalFormat) nf;
        DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();

        // set the beginning of the range to Arabic digits
        dfs.setZeroDigit('\u0660');
        df.setDecimalFormatSymbols(dfs);
    }//from ww  w  .  j  a  v a  2 s .c o m

    JLabel label = new JLabel(nf.format(1234567.89));

    label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
    add(label);
}

From source file:Main.java

/**
 * Changes font to plain for the specified component.
 *
 * @param component/*  www  .  j a  va  2 s .c  om*/
 *            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 setPlainFont(final C component, final boolean apply) {
    if (apply && component != null && component.getFont() != null) {
        component.setFont(component.getFont().deriveFont(Font.PLAIN));
    }
    return component;
}

From source file:MainClass.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, 32);

    TextLayout textLayout = new TextLayout(s, font, g2.getFontRenderContext());
    textLayout.draw(g2, 40, 80);/*from  w  w w  .  ja v  a2s . c om*/
}

From source file:Main.java

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

From source file:Main.java

public void paint(Graphics g) {
    Font f = g.getFont();//from w ww  .  j av a 2  s  .  co  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);
}