You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Zeichenflaeche.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package grafik;
  7. import java.awt.BasicStroke;
  8. import java.awt.Color;
  9. import java.awt.Graphics;
  10. import java.awt.Graphics2D;
  11. import java.awt.RenderingHints;
  12. import java.awt.geom.Ellipse2D;
  13. import java.awt.geom.Line2D;
  14. import javax.swing.JComponent;
  15. /**
  16. *
  17. * @author chris, hd
  18. */
  19. public class Zeichenflaeche extends JComponent // JPanel
  20. {
  21. private Line2D.Double line;
  22. private BasicStroke pinsel;
  23. private static final float DICKE = 30f;
  24. public Zeichenflaeche()
  25. {
  26. line = new Line2D.Double();
  27. pinsel = new BasicStroke(DICKE);
  28. }
  29. @Override
  30. public void paintComponent(Graphics g)
  31. {
  32. super.paintComponent(g);
  33. Graphics2D g2 = (Graphics2D)g;
  34. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  35. RenderingHints.VALUE_ANTIALIAS_ON);
  36. int breite = this.getWidth() - 1;
  37. int hoehe = this.getHeight() - 1;
  38. line.x1 = breite/2;
  39. line.y1 = hoehe/2;
  40. line.x2 = 30;
  41. line.y2 = 50;
  42. // line.setFrame(DICKE/2, DICKE/2, breite-DICKE, hoehe-DICKE);
  43. g2.setStroke(pinsel);
  44. g2.setPaint(Color.RED);
  45. g2.fill(line);
  46. g2.setPaint(Color.BLACK);
  47. g2.draw(line);
  48. }
  49. }