List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:JTextAreaDemo.java
public JTextAreaDemo() { super("JTextAreaDemo"); GraphicsEnvironment.getLocalGraphicsEnvironment(); Font font = new Font("LucidaSans", Font.PLAIN, 40); JTextArea textArea = new JTextArea(davidMessage + andyMessage); textArea.setFont(font);/*from w ww . ja v a2s .co m*/ this.getContentPane().add(textArea); textArea.show(); }
From source file:Main.java
public Main() { DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); dfs.setZeroDigit('\u0660'); df.setDecimalFormatSymbols(dfs);// ww w . j a va 2s.co m JLabel label = new JLabel(df.format(1234567.89)); label.setFont(new Font("Lucida Sans", Font.PLAIN, 22)); add(label); }
From source file:Main.java
public Main() { setSize(300, 150);// w ww . j a v a 2s. c o m setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout()); 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:Main.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, 72); g2.setFont(font);//from w w w. jav a 2s . c o m String s = "this is a test"; float x = 50, y = 150; // Draw the baseline. FontRenderContext frc = g2.getFontRenderContext(); float width = (float) font.getStringBounds(s, frc).getWidth(); Line2D baseline = new Line2D.Float(x, y, x + width, y); g2.setPaint(Color.red); g2.draw(baseline); // Draw the ascent. LineMetrics lm = font.getLineMetrics(s, frc); Line2D ascent = new Line2D.Float(x, y - lm.getAscent(), x + width, y - lm.getAscent()); g2.draw(ascent); // Draw the descent. Line2D descent = new Line2D.Float(x, y + lm.getDescent(), x + width, y + lm.getDescent()); g2.draw(descent); // Draw the leading. Line2D leading = new Line2D.Float(x, y + lm.getDescent() + lm.getLeading(), x + width, y + lm.getDescent() + lm.getLeading()); g2.draw(leading); // Render the string. g2.setPaint(Color.black); g2.drawString(s, x, y); }
From source file:FontDerivation.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Create a 1-point font. Font font = new Font("Serif", Font.PLAIN, 1); float x = 20, y = 20; Font font24 = font.deriveFont(24.0f); g2.setFont(font24);/*w w w . ja v a 2 s .c o m*/ g2.drawString("font.deriveFont(24.0f)", x, y += 30); Font font24italic = font24.deriveFont(Font.ITALIC); g2.setFont(font24italic); g2.drawString("font24.deriveFont(Font.ITALIC)", x, y += 30); AffineTransform at = new AffineTransform(); at.shear(.2, 0); Font font24shear = font24.deriveFont(at); g2.setFont(font24shear); g2.drawString("font24.deriveFont(at)", x, y += 30); Hashtable attributes = new Hashtable(); attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); Font font24bold = font24.deriveFont(attributes); g2.setFont(font24bold); g2.drawString("font24.deriveFont(attributes)", x, y += 30); }
From source file:FontShow.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Dialog", Font.PLAIN, 96); g2.setFont(font);/*from w ww .j av a2 s .com*/ int width = getSize().width; int height = getSize().height; String message = "Java2s"; FontRenderContext frc = g2.getFontRenderContext(); LineMetrics metrics = font.getLineMetrics(message, frc); float messageWidth = (float) font.getStringBounds(message, frc).getWidth(); // center text float ascent = metrics.getAscent(); float descent = metrics.getDescent(); float x = (width - messageWidth) / 2; float y = (height + metrics.getHeight()) / 2 - descent; int PAD = 25; g2.setPaint(getBackground()); g2.fillRect(0, 0, width, height); g2.setPaint(getForeground()); g2.drawString(message, x, y); g2.setPaint(Color.white); // Base lines drawLine(g2, x - PAD, y, x + messageWidth + PAD, y); drawLine(g2, x, y + PAD, x, y - ascent - PAD); g2.setPaint(Color.green); // Ascent line drawLine(g2, x - PAD, y - ascent, x + messageWidth + PAD, y - ascent); g2.setPaint(Color.red); // Descent line drawLine(g2, x - PAD, y + descent, x + messageWidth + PAD, y + descent); }
From source file:LineMetricsIllustration.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, 72); g2.setFont(font);/* w w w . j av a2s .c o m*/ String s = "Java Source and Support"; float x = 50, y = 150; // Draw the baseline. FontRenderContext frc = g2.getFontRenderContext(); float width = (float) font.getStringBounds(s, frc).getWidth(); Line2D baseline = new Line2D.Float(x, y, x + width, y); g2.setPaint(Color.red); g2.draw(baseline); // Draw the ascent. LineMetrics lm = font.getLineMetrics(s, frc); Line2D ascent = new Line2D.Float(x, y - lm.getAscent(), x + width, y - lm.getAscent()); g2.draw(ascent); // Draw the descent. Line2D descent = new Line2D.Float(x, y + lm.getDescent(), x + width, y + lm.getDescent()); g2.draw(descent); // Draw the leading. Line2D leading = new Line2D.Float(x, y + lm.getDescent() + lm.getLeading(), x + width, y + lm.getDescent() + lm.getLeading()); g2.draw(leading); // Render the string. g2.setPaint(Color.black); g2.drawString(s, x, y); }
From source file:TexturedText.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Times New Roman", Font.PLAIN, 72); g2.setFont(font);/*from ww w . j ava 2 s. co m*/ String s = "Java Source and Support"; Dimension d = getSize(); float x = 20, y = 100; BufferedImage bi = getTextureImage(); Rectangle r = new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); TexturePaint tp = new TexturePaint(bi, r); g2.setPaint(tp); g2.drawString(s, x, y); }
From source file:ArabicDigitsI18N.java
public ArabicDigitsI18N() { DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); dfs.setZeroDigit('\u0660'); df.setDecimalFormatSymbols(dfs);//w w w . jav a2 s.c om JLabel label = new JLabel(df.format(1234567.89)); label.setFont(new Font("Lucida Sans", Font.PLAIN, 22)); add(label); }
From source file:PrintLineByLine.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 a 2s. c o m*/ g2d.setFont(new Font("Purisa", Font.PLAIN, 13)); g2d.drawString("Line 1", 20, 30); g2d.drawString("Line 2", 20, 60); g2d.drawString("Line 3", 20, 90); g2d.drawString("Line 4", 20, 120); g2d.drawString("Line 5", 20, 150); g2d.drawString("Line 6", 20, 180); }