Posted By

whitetiger on 11/09/06


Tagged

css javascript java html rails ruby flickr web webwork swing applet unicode


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

olivernautsch


Java - Applet DrawLine


 / Published in: Java
 

  1. <html>
  2.  
  3. <head>
  4. <title>Sono una Applet...</title>
  5. </head>
  6.  
  7. <body>
  8. <applet code="Example01.class" width="300" height="300">Non sono supportata...</applet>
  9. </body>
  10.  
  11. </html>
  12.  
  13.  
  14. import java.awt.Color;
  15. import java.awt.Graphics;
  16. import java.awt.event.MouseEvent;
  17. import java.awt.event.MouseMotionListener;
  18.  
  19. import javax.swing.JApplet;
  20.  
  21. public class Example01 extends JApplet implements MouseMotionListener
  22. {
  23. public void init()
  24. {
  25. this.addMouseMotionListener(this);
  26. }
  27.  
  28. public void start()
  29. {
  30. this.setBackground(Color.YELLOW);
  31. this.repaint(); // Ridisegna lo schermo
  32. }
  33.  
  34. public void paint(Graphics g)
  35. {
  36. super.paint(g);
  37. }
  38.  
  39. public void mouseDragged(MouseEvent e)
  40. {
  41.  
  42. }
  43.  
  44. public void mouseMoved(MouseEvent e)
  45. {
  46. Graphics g = this.getGraphics();
  47.  
  48. g.drawLine(e.getX(), e.getY(), e.getX(), e.getY());
  49. }
  50. }

Report this snippet  

You need to login to post a comment.