Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. /**
  2. * AWT Sample application
  3. *
  4. * @author
  5. * @version 1.00 20/02/20
  6. */
  7.  
  8.  
  9. import java.awt.*;
  10. import java.awt.event.*;
  11. import javax.swing.*;
  12. import java.util.*;
  13.  
  14. public class TulaganPeterjones2 extends JPanel implements MouseListner {
  15. private Vector v;
  16. public TulaganPeterjones2 (){
  17. V = new Vector();
  18. setBackground(Color.white);
  19. addMouseListener(this);
  20. }
  21.  
  22. public static void main(Graphics g) {//paint () method
  23. super.paint(g);
  24. g.setColor(Color.black);
  25. Enumeration enumeration = v.elements();
  26. while(enumeration.hasMoreElements()){
  27. Point p = (Point) (enumeration.nextElement());
  28. g.drawRect(p.x-20, p.y-20,40,40);
  29. }
  30. public void MousePressed(MouseEvent me);{
  31. v.add(me.getPoint());
  32. repaint();//call repaint()method
  33. }
  34. // TODO, ad your application code
  35. System.out.println("Hello Wolrd");
  36. }
  37. public void mouseClicked(MouseEvent me){}
  38. public void mouseEntered(MouseEvent me){}
  39. public void mouseExited(MouseEvent me){}
  40. public void mouseReleased(MouseEvent me){}
  41. public static void main(String args[]){
  42. Jframe frame = new Jframe();
  43. frame.getContentPane().add(new TulaganPeterjones2());
  44. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45. frame.setLocationRelativeTo(null);
  46. frame.setSize(375,250);
  47. frame.setVisible(true);
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement