Advertisement
anhit92

Vẽ tam giác

Jun 13th, 2013
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package vetamgiac;
  2.  
  3. /**
  4. *
  5. * @author thieumao
  6. */
  7. import java.awt.event.*;
  8. import javax.swing.*;
  9.  
  10. public class VeTamGiac extends JPanel implements MouseListener {
  11.  
  12. int x1, x2, x3, y1, y2, y3;
  13.  
  14. public static void main(String[] args) {
  15. JFrame frame = new JFrame();
  16. frame.add(new VeTamGiac());
  17. frame.setSize(400, 400);
  18. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19. frame.setVisible(true);
  20. }
  21.  
  22. public VeTamGiac() {
  23. super();
  24. addMouseListener(this);
  25. }
  26.  
  27. public void mouseClicked(MouseEvent e) {
  28. }
  29.  
  30. public void mouseEntered(MouseEvent e) {
  31. }
  32.  
  33. public void mouseExited(MouseEvent e) {
  34. }
  35.  
  36. public void mouseReleased(MouseEvent e) {
  37. x1 = 100;
  38. y1 = 100;
  39. x2 = 200;
  40. y2 = 100;
  41. x3 = 200;
  42. y3 = 200;
  43. getGraphics().drawLine(x1, y1, x2, y2);
  44. getGraphics().drawLine(x2, y2, x3, y3);
  45. getGraphics().drawLine(x3, y3, x1, y1);
  46. }
  47.  
  48. public void mousePressed(MouseEvent e) {
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement