Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. public BufferedImage image[] = new BufferedImage[5];
  2. int ClassType = 0 ;
  3. int x =150;
  4. public MPaneel() {
  5. class DogeWarrior implements MouseListener
  6. {
  7. int Strength;
  8. int Hp;
  9.  
  10. public void ShowPic()
  11. {
  12. try {
  13.  
  14. image[ClassType] = ImageIO.read(new File("src/Opdracht/DogeWarrior69.png"));
  15.  
  16. ClassType++;
  17. } catch (IOException ex) {
  18. // handle exception...
  19. }
  20. }
  21.  
  22. @Override
  23. public void mouseClicked(MouseEvent e) {
  24.  
  25.  
  26. }
  27.  
  28. @Override
  29. public void mouseEntered(MouseEvent e) {
  30. // TODO Auto-generated method stub
  31.  
  32. }
  33.  
  34. @Override
  35. public void mouseExited(MouseEvent e) {
  36. // TODO Auto-generated method stub
  37.  
  38. }
  39.  
  40. @Override
  41. public void mousePressed(MouseEvent e) {
  42. // TODO Auto-generated method stub
  43.  
  44. }
  45.  
  46. @Override
  47. public void mouseReleased(MouseEvent e) {
  48. // TODO Auto-generated method stub
  49.  
  50. }
  51. }
  52. class Elephant
  53. {
  54.  
  55. int Strength;
  56. int Hp;
  57. public void ShowPic()
  58. {
  59. try {
  60. image[ClassType] = ImageIO.read(new File("src/Opdracht/Elephant.jpg"));
  61.  
  62. ClassType++;
  63. } catch (IOException ex) {
  64.  
  65. }
  66. }
  67.  
  68.  
  69. }
  70. class PooTart
  71. {
  72. int Strength;
  73. int Hp;
  74. public void ShowPic()
  75. {
  76. try {
  77. image[ClassType] = ImageIO.read(new File("src/Opdracht/PooTart.jpg"));
  78.  
  79. ClassType++;
  80. } catch (IOException ex) {
  81.  
  82. }
  83. }
  84. }
  85. DogeWarrior a = new DogeWarrior();
  86. a.ShowPic();
  87.  
  88. Elephant b = new Elephant();
  89. b.ShowPic();
  90.  
  91. PooTart c = new PooTart();
  92. c.ShowPic();
  93.  
  94.  
  95. }
  96.  
  97.  
  98. public void paintComponent(Graphics g) {
  99. super.paintComponent(g);
  100.  
  101.  
  102. for (int i = 0; i < image.length; i++) {
  103. if(image[i] != null) {
  104. image[i].getScaledInstance(100, 100, java.awt.Image.SCALE_SMOOTH);
  105.  
  106. x=x+50;
  107. g.drawImage(image[i], x, 0,50,50, null);
  108. // JOptionPane.showMessageDialog(null, x);
  109. // do some work here on intValue
  110. }
  111. }
  112. }
  113.  
  114.  
  115. @Override
  116. public void mouseClicked(MouseEvent arg0) {
  117. // TODO Auto-generated method stub
  118.  
  119. }
  120.  
  121.  
  122. @Override
  123. public void mouseEntered(MouseEvent arg0) {
  124. // TODO Auto-generated method stub
  125.  
  126. }
  127.  
  128.  
  129. @Override
  130. public void mouseExited(MouseEvent arg0) {
  131. // TODO Auto-generated method stub
  132.  
  133. }
  134.  
  135.  
  136. @Override
  137. public void mousePressed(MouseEvent arg0) {
  138. // TODO Auto-generated method stub
  139.  
  140. }
  141.  
  142.  
  143. @Override
  144. public void mouseReleased(MouseEvent arg0) {
  145. // TODO Auto-generated method stub
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement