怎样把在JPanel画了的图案保存,然后提取

来源:百度知道 编辑:UC知道 时间:2024/06/21 22:49:01
public class window implements MouseListener,MouseMotionListener
{
private boolean D=true;
private int nx,ny,tx,ty;
public JFrame frame=new JFrame("DrawPane");
void window()
{
frame.setSize(300,300);frame.setBackground(Color.red);frame.setVisible(true);
frame.addMouseListener(this);
frame.addMouseMotionListener(this);
}
public static void main(String [] arg)
{
new window().window();
}

public void mouseDragged(MouseEvent e){tx=nx;ty=ny; nx=e.getX(); ny=e.getY();G();}
public void mouseMoved(MouseEvent e){}/* */
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e){ nx=e.getX(); ny=e.getY();}
public void mouseReleased(MouseEvent e){D=false;}

public void G()
{
Graphics G=frame.getGraphics();

public class window implements MouseListener, MouseMotionListener {

private boolean D = true;
private int nx, ny, tx, ty;
public JFrame frame = new JFrame("DrawPane");
private BufferedImage iamge;
private ArrayList<DrawLineClass> list = new ArrayList<DrawLineClass>();

void window() {
frame.setSize(300, 300);
iamge = new BufferedImage(300, 300, BufferedImage.TYPE_4BYTE_ABGR);
frame.setBackground(Color.red);
frame.setVisible(true);
frame.addMouseListener(this);
frame.addMouseMotionListener(this);
}

public static void main(String[] arg) {
new window().window();
}

public void mouseDragged(MouseEvent e) {
tx = nx;
ty = ny;
nx = e.getX();
ny = e.getY();
G();
}

public void mou