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.

FlaecheBeet.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.Color;
  8. import java.awt.Graphics;
  9. import javax.swing.JPanel;
  10. /**
  11. *
  12. * @author Jan
  13. */
  14. public class FlaecheBeet extends JPanel
  15. {
  16. int[] randomwertex;
  17. int[] randomwertey;
  18. Color colorBeet;
  19. public FlaecheBeet()
  20. {
  21. randomwertex = new int[4];
  22. randomwertey = new int[4];
  23. colorBeet = new Color(153, 102, 51);
  24. }
  25. public void paintComponent(Graphics g)
  26. {
  27. super.paintComponent(g);
  28. g.setColor(colorBeet);
  29. for (int i = 0; i < randomwertex.length - 1; i++)
  30. {
  31. for (int j = 0; j < randomwertey.length - 1; j++)
  32. {
  33. g.fillRect(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1] - randomwertex[i] - 20, randomwertey[j + 1] - randomwertey[j] - 20);
  34. }
  35. }
  36. }
  37. public void setBeet(int[] x, int[] y)
  38. {
  39. randomwertex = x;
  40. randomwertey = y;
  41. repaint();
  42. }
  43. }