Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package ExerciseFour;
  2.  
  3. import java.awt.*;
  4. import java.io.FileNotFoundException;
  5.  
  6. import javax.swing.*;
  7.  
  8.  
  9. class Board extends JPanel {
  10. Boolean[][] maze = getMaze();
  11. int row = maze.length;
  12. private Ball b = new Ball();
  13.  
  14.  
  15. public Boolean[][] getMaze() throws FileNotFoundException {
  16. Boolean[][] maze = Exercise4.getMaze();
  17. return maze;
  18. }
  19.  
  20. public Board() throws FileNotFoundException {
  21. add(b);
  22. }
  23.  
  24. public void paintComponent(Graphics g) {
  25. super.paintComponent(g);
  26. for (int y = 0; y < row; y++) {
  27. for (int x = 0; x < row; x++) {
  28.  
  29. if (maze[y][x].equals(false)) {
  30. g.setColor(Color.BLACK);
  31. g.fillRect(x * 25, y * 25, 120, 120);
  32. } else {
  33. g.setColor(Color.WHITE);
  34. g.fillRect(x * 25, y * 25, 120, 120);
  35. }
  36. }
  37. }
  38. g.setColor(Color.RED);
  39. g.fillOval((row - 1) * 24 - 5, (row - 1) * 24 - 5, 20, 20);
  40.  
  41. }
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement