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.

FlaecheWeg.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 garten.view;
  7. import java.awt.BasicStroke;
  8. import java.awt.Color;
  9. import java.awt.Graphics;
  10. import java.awt.Graphics2D;
  11. import javax.swing.JPanel;
  12. /**
  13. *
  14. * @author Jan
  15. */
  16. public class FlaecheWeg extends JPanel
  17. {
  18. int[] randomwertex;
  19. int[] randomwertey;
  20. private BasicStroke pinsel;
  21. Color colorWeg;
  22. public FlaecheWeg()
  23. {
  24. randomwertex = new int[4];
  25. randomwertey = new int[4];
  26. pinsel = new BasicStroke(6f);
  27. colorWeg = new Color(190, 190, 190);
  28. }
  29. public void paintComponent(Graphics g)
  30. {
  31. super.paintComponent(g);
  32. Graphics2D g2 = (Graphics2D) g;
  33. g2.setColor(colorWeg);
  34. g2.setStroke(pinsel);
  35. for (int i = 0; i < randomwertex.length; i++)
  36. {
  37. g2.drawLine(randomwertex[i], randomwertey[0], randomwertex[i], randomwertey[3]);
  38. g2.drawLine(randomwertex[0], randomwertey[i], randomwertex[3], randomwertey[i]);
  39. }
  40. }
  41. public void setWeg(int[] x, int[] y)
  42. {
  43. randomwertex = x;
  44. randomwertey = y;
  45. repaint();
  46. }
  47. }