Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * AWT Sample application
- *
- * @author
- * @version 1.00 20/02/20
- */
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.util.*;
- public class TulaganPeterjones2 extends JPanel implements MouseListner {
- private Vector v;
- public TulaganPeterjones2 (){
- V = new Vector();
- setBackground(Color.white);
- addMouseListener(this);
- }
- public static void main(Graphics g) {//paint () method
- super.paint(g);
- g.setColor(Color.black);
- Enumeration enumeration = v.elements();
- while(enumeration.hasMoreElements()){
- Point p = (Point) (enumeration.nextElement());
- g.drawRect(p.x-20, p.y-20,40,40);
- }
- public void MousePressed(MouseEvent me);{
- v.add(me.getPoint());
- repaint();//call repaint()method
- }
- // TODO, ad your application code
- System.out.println("Hello Wolrd");
- }
- public void mouseClicked(MouseEvent me){}
- public void mouseEntered(MouseEvent me){}
- public void mouseExited(MouseEvent me){}
- public void mouseReleased(MouseEvent me){}
- public static void main(String args[]){
- Jframe frame = new Jframe();
- frame.getContentPane().add(new TulaganPeterjones2());
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- frame.setSize(375,250);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement