Kruispunt.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Write a description of class Kruispunt here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. import java.awt.geom.*;
  8. import javax.swing.*;
  9. import java.awt.event.*;
  10. import java.awt.*;
  11. import java.awt.image.*;
  12. import java.io.*;
  13. import javax.imageio.*;
  14. public class Kruispunt extends JLabel
  15. {
  16. BufferedImage kruispunt;
  17. public Kruispunt()
  18. {
  19. try{
  20. kruispunt = ImageIO.read(new File("kruispunt.png"));
  21. }catch (IOException e){
  22. }
  23. this.repaint();
  24. }
  25. public void setBoebot(int rotation)
  26. {
  27. if(rotation == 90)
  28. {
  29. try{
  30. kruispunt = ImageIO.read(new File("boebot.png"));
  31. }catch (IOException e){
  32. }
  33. }
  34. if(rotation == 0)
  35. {
  36. try{
  37. kruispunt = ImageIO.read(new File("boven boebot.png"));
  38. }catch (IOException e){
  39. }
  40. }
  41. if(rotation == 180)
  42. {
  43. try{
  44. kruispunt = ImageIO.read(new File("onder boebot.png"));
  45. }catch (IOException e){
  46. }
  47. }
  48. if(rotation == 270)
  49. {
  50. try{
  51. kruispunt = ImageIO.read(new File("links boebot.png"));
  52. }catch (IOException e){
  53. }
  54. }
  55. this.repaint();
  56. }
  57. public void setGat()
  58. {
  59. try{
  60. kruispunt = ImageIO.read(new File("gat.png"));
  61. }catch (IOException e){
  62. }
  63. this.repaint();
  64. }
  65. public void setFinish()
  66. {
  67. try{
  68. kruispunt = ImageIO.read(new File("finish.png"));
  69. }catch (IOException e){
  70. }
  71. this.repaint();
  72. }
  73. protected void paintComponent(Graphics g){
  74. super.paintComponent(g);
  75. Graphics2D g2 = (Graphics2D) g;
  76. g2.drawImage(kruispunt, 0, 0, null);
  77. }
  78. }