setClip
public void setClip(int x,
int y,
int width,
int height)Sets the current clip to the rectangle specified by the given coordinates. Rendering operations have no effect outside of the clipping area.
Parameters:
x - the x coordinate of the new clip rectangle
y - the y coordinate of the new clip rectangle
width - the width of the new clip rectangle
height - the height of the new clip rectangle
See Also:
clipRect(int, int, int, int)
// use this statement to create a file to save the jpg.
FileOutputStream os=new FileOutputStream("e:/x01.jpg");
encoder = JPEGCodec.createJPEGEncoder(os);
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.drawLine(30,30,90,90);
encoder.encode(image);
os.flush();
os.close();