/* * 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 grafik; 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 java.awt.geom.Line2D; import javax.swing.JComponent; /** * * @author chris, hd */ public class Zeichenflaeche extends JComponent // JPanel { private Line2D.Double line; private BasicStroke pinsel; private static final float DICKE = 30f; public Zeichenflaeche() { line = new Line2D.Double(); 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; line.x1 = breite/2; line.y1 = hoehe/2; line.x2 = 30; line.y2 = 50; // line.setFrame(DICKE/2, DICKE/2, breite-DICKE, hoehe-DICKE); g2.setStroke(pinsel); g2.setPaint(Color.RED); g2.fill(line); g2.setPaint(Color.BLACK); g2.draw(line); } }