public void pencil1()
{
k1=2;
setDoubleBuffered(false);
cursorchange();
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent e){
oldX = e.getX();
oldY = e.getY();
}
});
//if the mouse is pressed it sets the oldX & oldY
//coordinates as the mouses x & y coordinates
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
currentX = e.getX();
currentY = e.getY();
if(graphics2D != null && k1==1)
graphics2D.drawLine(oldX, oldY, currentX,currentY);
repaint();
oldX = currentX;
oldY = currentY;
repaint();
hello, i'm having problem to understand the code. can somebody help me? this isn't my code, i'm just trying to learn