Drawing a line
import java.util.ArrayList;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.*;
public class LinePanel extends JPanel
{
private ArrayList<Point> pointList;
private int x, y, x2, y2;
public LinePanel()
{
pointList = new ArrayList<Point>();
addMouseListener (new LineListener());
setBackground (Color.black);
setPreferredSize (new Dimension(300, 300));
}
public void paintComponent (Graphics page)
{
super.paintComponent(page);
page.setColor (Color.yellow);
page.drawLine (x);
}
private class LineListener implements MouseListener
{
public void mousePressed (MouseEvent event)
{
pointList.add(event.getPoint());
repaint();
}
public void mouseClicked (MouseEvent event) {}
public void mouseReleased (MouseEvent event) {}
public void mouseEntered (MouseEvent event) {}
public void mouseExited (MouseEvent event) {}
}
}
this is my program but its obviously incomplete, how do i make the different x and y variables from the array list so that i can draw a line by clicking in two different places on the panel. If my question is too confusing (im bad at wording it right) let me know and ill try again.

