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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 grafik2d;
  7. /**
  8. *
  9. * @author nobody
  10. */
  11. import java.awt.BasicStroke;
  12. import java.awt.Color;
  13. import java.awt.Graphics;
  14. import java.awt.Graphics2D;
  15. import java.awt.RenderingHints;
  16. import java.awt.geom.Ellipse2D;
  17. import javax.swing.JComponent;
  18. /**
  19. *
  20. * @author le
  21. */
  22. public class Zeichenflaeche extends JComponent // JPanel
  23. {
  24. private Ellipse2D.Float ellipse;
  25. private BasicStroke pinsel;
  26. private static final float DICKE = 30f;
  27. public Zeichenflaeche()
  28. {
  29. ellipse = new Ellipse2D.Float();
  30. pinsel = new BasicStroke(DICKE);
  31. }
  32. @Override
  33. public void paintComponent(Graphics g)
  34. {
  35. super.paintComponent(g);
  36. Graphics2D g2 = (Graphics2D)g;
  37. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  38. RenderingHints.VALUE_ANTIALIAS_ON);
  39. int breite = this.getWidth() - 1;
  40. int hoehe = this.getHeight() - 1;
  41. ellipse.setFrame(DICKE/2, DICKE/2, breite-DICKE, hoehe-DICKE);
  42. g2.setStroke(pinsel);
  43. g2.setPaint(Color.RED);
  44. g2.fill(ellipse);
  45. g2.setPaint(Color.BLACK);
  46. g2.draw(ellipse);
  47. }
  48. }