/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package grafik2d; /** * * @author nobody */ import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.Ellipse2D; import javax.swing.JComponent; /** * * @author le */ public class Zeichenflaeche extends JComponent // JPanel { private Ellipse2D.Float ellipse; private BasicStroke pinsel; private static final float DICKE = 30f; public Zeichenflaeche() { ellipse = new Ellipse2D.Float(); pinsel = new BasicStroke(DICKE); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int breite = this.getWidth() - 1; int hoehe = this.getHeight() - 1; ellipse.setFrame(DICKE/2, DICKE/2, breite-DICKE, hoehe-DICKE); g2.setStroke(pinsel); g2.setPaint(Color.RED); g2.fill(ellipse); g2.setPaint(Color.BLACK); g2.draw(ellipse); } }