import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.geom.*;


public class  mouseP extends JPanel implements MouseListener,MouseMotionListener
{
  //push-move-release line draw
  int x1,y1,x2,y2;
  Color c;
  boolean first;
  Line2D x;
  
 public mouseP()
 {super();
  x1=0;y1=0;x2=0;y2=0;
  first=true;
  addMouseListener(this);
  addMouseMotionListener(this);
 }
 
 public mouseP(int x1i,int y1i,int x2i,int y2i)
 {super();
  x1=x1i;y1=y1i;x2=x2i;y2=y2i;
  first=true;
 addMouseListener(this);
 addMouseMotionListener(this);
 }
 
 public void setLine(int x1i,int y1i,int x2i,int y2i)
 {x1=x1i;y1=y1i;x2=x2i;y2=y2i;}
 

 public void paint(Graphics g)
 {
 super.paintComponent(g);
 Graphics2D g2=(Graphics2D)g;	 
 g2.setFont(new Font("Serif",Font.BOLD,24));	 
 g2.setColor(Color.blue);
 g2.setStroke(new BasicStroke(2.0f));
 x=new Line2D.Double(x1,y1,x2,y2);
 g2.draw(x);	 
 }
    
//MouseListener
public void mouseClicked(MouseEvent e)
 {}

 public void mousePressed(MouseEvent e)
 {
   x1=e.getX();y1=e.getY();}

  public void mouseReleased(MouseEvent e)
 { x2=e.getX();y2=e.getY();repaint();}

 public void mouseEntered(MouseEvent e)
 { }

 public void mouseExited(MouseEvent e)
 { }
 
//MouseMotionListener

 public void mouseDragged(MouseEvent e)
 {}
 public void mouseMoved(MouseEvent e)
 {}
 
}
