解决方法
如果您希望用户能够“单击并拖动”以选择矩形,则需要实现
MouseMotionListener
.请查看mouseDragged方法:
@H_403_2@@H_403_2@当你需要掌握子图像时,你只需使用void mouseDragged(MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged.
@H_403_2@@H_403_2@如果要将生成的图像保存到磁盘,建议您查看Saving a Generated Graphic to a PNG or JPEG File.public BufferedImage getSubimage(int x,int y,int w,int h)
Returns a subimage defined by a specified rectangular region. The returned BufferedImage shares the same data array as the original image.