GraphicsDrawChars.java Source code

Java tutorial

Introduction

Here is the source code for GraphicsDrawChars.java

Source

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(400, 400);
        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, 10, 30);
    }
}