Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vetamgiac;
- /**
- *
- * @author thieumao
- */
- import java.awt.event.*;
- import javax.swing.*;
- public class VeTamGiac extends JPanel implements MouseListener {
- int x1, x2, x3, y1, y2, y3;
- public static void main(String[] args) {
- JFrame frame = new JFrame();
- frame.add(new VeTamGiac());
- frame.setSize(400, 400);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- }
- public VeTamGiac() {
- super();
- addMouseListener(this);
- }
- public void mouseClicked(MouseEvent e) {
- }
- public void mouseEntered(MouseEvent e) {
- }
- public void mouseExited(MouseEvent e) {
- }
- public void mouseReleased(MouseEvent e) {
- x1 = 100;
- y1 = 100;
- x2 = 200;
- y2 = 100;
- x3 = 200;
- y3 = 200;
- getGraphics().drawLine(x1, y1, x2, y2);
- getGraphics().drawLine(x2, y2, x3, y3);
- getGraphics().drawLine(x3, y3, x1, y1);
- }
- public void mousePressed(MouseEvent e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement