/**
*
*/
package de.tutorials;
import java.awt.BasicStroke;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
import javax.swing.JFrame;
/**
* @author Tom
*/
public class SimpleStrokeExample extends JFrame {
private Stroke stroke = new BasicStroke(10.0F);
private final static int RADIUS = 50;
private final static int DIAMETER = 2 * RADIUS;
private final static int CIRCLE_COUNT = 6;
private final static Font font = new Font("Arial", Font.BOLD, 32);
public SimpleStrokeExample() {
super("SimpleStrokeExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(DIAMETER * CIRCLE_COUNT + RADIUS, DIAMETER + RADIUS);
setResizable(false);
setVisible(true);
}
public void paint(Graphics graphics) {
Graphics2D g = (Graphics2D) graphics;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setStroke(stroke);
g.setFont(font);
for (int i = 0, x = RADIUS; i < CIRCLE_COUNT; i++, x += DIAMETER) {
g.drawString("" + i, x + RADIUS / 2 - 9, (DIAMETER + RADIUS) / 2+12);
g.drawOval(x, RADIUS, RADIUS, RADIUS);
}
}
/**
* @param args
*/
public static void main(String[] args) {
new SimpleStrokeExample();
}
}