public void drawLine(int x0,int y0,int x1,int y1){
  Line2D line=new Line2D.Float(x0,y0,x1,y1);
  if (g.getClipBounds() == null || line.intersects(g.getClipBounds())) {
    g.draw(line);
  }
}

public void drawLine ( int x0 , int y0 , int x1 , int y1 ) { Line2D line = new Line2D . Float ( x0 , y0 , x1 , y1 ) ; if ( g . getClipBounds ( ) == null || line . intersects ( g . getClipBounds ( ) ) ) { g . draw ( line ) ; } }
draws the given line if the line is inside the clipping area . this method assumes that the stroke on the graphics object is already set .
