Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Paesaggio - paes.java

paes.java

Caricato da: Netarrow
Scarica il programma completo

  1. /*
  2.  * Created on 2-gen-2004
  3.  */
  4.  
  5. /**
  6.  * @author Matteo Tomasulo
  7.  */
  8. import java.applet.*;
  9. import java.awt.*;
  10. import java.awt.event.*;
  11.  
  12. public class paes extends Applet implements MouseMotionListener, MouseListener {
  13. Image pa;
  14. int x = 0, y = 0;
  15. int mx = 0, my = 0;
  16.  
  17. public void init() {
  18.         addMouseMotionListener(this);
  19.         pa = getImage(getCodeBase(), "im/p.jpg");
  20. }
  21.  
  22. public void mousePressed(MouseEvent e) {
  23. }
  24.  
  25. public void mouseEntered(MouseEvent e) {
  26. }
  27.  
  28. public void mouseExited(MouseEvent e) {
  29. }
  30.  
  31. public void mouseClicked(MouseEvent e) {
  32. }
  33.  
  34. public void mouseReleased(MouseEvent e) {
  35. }
  36.  
  37. public void mouseDragged(MouseEvent e) {
  38.        
  39. }
  40.  
  41. public void mouseMotion(MouseEvent e) {
  42.  
  43. }
  44.  
  45. public void mouseMoved(MouseEvent e) {
  46.         if(mx < e.getX() && my < e.getY()) {
  47. if((x >= -210 && y >= -323)) {
  48.         y -= 1;
  49.         x -= 1;
  50.          repaint();
  51. }
  52.         }
  53.         else if(mx > e.getX() && my > e.getY()) {
  54.                 if((x <= 0 && y <= 0)) {
  55.         y += 1;
  56.         x += 1;
  57.          repaint();}
  58.         }
  59.         else if(mx < e.getX() && my > e.getY()) {
  60.                 if((x >= -212 && y >= -323 && x <= 0 && y <= 0)) {
  61.         y += 1;
  62.         x -= 1;
  63.           repaint();}
  64.         }
  65.         else if(mx > e.getX() && my < e.getY()) {
  66.                 if((x >= -210 && y >= -323 && x <= 0 && y <= 0)) {
  67.                 y -= 1;
  68.                 x += 1;
  69.                   repaint(); }
  70.                 }
  71.         else if(mx == e.getX() && my < e.getY()) {
  72.                 if((x >= -210 && y >= -323 && x <= 0 && y <= 0)) {
  73.                         y -= 1;
  74.                           repaint();    }
  75.                         }
  76.         else if(mx < e.getX() && my == e.getY()) {
  77.                 if((x >= -210 && y >= -323 && x <= 0 && y <= 0)) {
  78.                         x -= 1;
  79.                  repaint();}
  80.                         }
  81.         else if(mx > e.getX() && my == e.getY()) {
  82.                 if((x >= -210 && y >= -323 && x<= 0 && y <= 0)) {
  83.                         x += 1;
  84.                          repaint();     }
  85.                         }
  86.         else if(mx == e.getX() && my > e.getY()) {
  87.                 if((x >= -210 && y >= -323 && x<=0 && y<=0 )) {
  88.                         y += 1;
  89.                          repaint();     }
  90.                         }
  91.         mx = e.getX();
  92.         my = e.getY();         
  93. }
  94.  
  95. public void paint(Graphics g) {
  96.         g.drawImage(pa, x, y, this);
  97. showStatus("Cursore(" + mx + "," + my + ")");
  98. }
  99. }