Draw Chars : Draw Text « 2D Graphics « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » 2D Graphics » Draw Text 
16.20.4.Draw CharsPrevious/Next
Draw Chars
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GraphicsDrawChars extends JPanel {

  public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setSize(400400);
    f.add(new GraphicsDrawChars());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }

  public void paint(Graphics g) {
    char[] c = 'W''a''t''c''h'' ''i''t'' ''D''u''k''e''!' };

    g.drawChars(c, 0, c.length, 1030);
  }
}
16.20.Draw Text
16.20.1.How do I...Draw text?How do I...Draw text?
16.20.2.Getting the Dimensions of Text
16.20.3.draw Bytes
16.20.4.Draw CharsDraw Chars
16.20.5.Draw unicode with Graphics2D
16.20.6.use Text Attributes to style text
16.20.7.Drawing Simple Text
16.20.8.Drawing Rotated Text
16.20.9.Draw string rotated clockwise 45 degrees
16.20.10.Draw string rotated counter-clockwise 45 degrees
16.20.11.TextAttribute.FONT: Set font for AttributedString
16.20.12.TextAttribute.FOREGROUND: Set color for AttributedString
16.20.13.TextAttribute.UNDERLINE: Set underline for AttributedString
16.20.14.TextAttribute.BACKGROUND: Set background for AttributedString
16.20.15.TextAttribute.STRIKETHROUGH: Set STRIKETHROUGH for AttributedString
16.20.16.TextAttribute.SIZE: Set SIZE for AttributedString
16.20.17.TextAttribute.SUPERSCRIPT: Set SUPERSCRIPT for AttributedString
16.20.18.Center text based on font metrics
16.20.19.Create a shadowed text
16.20.20.Display underlined text
16.20.21.Display vertical text
16.20.22.Use AffineTransform to draw vertical text
16.20.23.Display unicode text
16.20.24.Display some lyrics on the panel.
16.20.25.Paint a calendar
16.20.26.Generate Shape From Text
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.