Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Paint extends Applet {
- private static final long serialVersionUID = 1L;
- int last_x, last_y;
- public void init() {
- this.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- last_x = e.getX(); last_y = e.getY();
- }
- });
- this.addMouseMotionListener(new MouseMotionAdapter() {
- public void mouseDragged(MouseEvent e) {
- Graphics g = getGraphics();
- int x = e.getX(), y= e.getY();
- g.setColor(Color.magenta);
- g.drawLine(last_x, last_y, x, y);
- last_x = x; last_y = y;
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement