时间不多,给你一点提示:
1、响应鼠标事件,选中的对象记入到Componet中。
2、响应键盘事件,当按中的健为"Delete",设置被选中的对象的visible=false;代码我没写,应该不麻烦。

解决方案 »

  1.   

    这个是联系你上一个问题的例子,用到的还是canvas,右键鼠标可以在区域里添加,选中一个canvas,然后按delete可以删除选中的对象,做到这里,我相信要实现流程图的绘制应该不难了import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.applet.*;public class applet6 extends Applet {
    canvas curCom=null;
    Image img1=null;
    int width=0,height=0;
    MediaTracker mt=new MediaTracker(this);
    public void init() {
    img1=this.getImage(this.getCodeBase(),"1.gif");//装载图片
    this.setLayout(null);
    mt.addImage(img1,0);
    try {
      mt.waitForAll();
    } catch(Exception ex) {System.err.println(ex.toString());}
    width=img1.getWidth(this);
    height=img1.getHeight(this);
    this.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        addcanvas(e);
      }
    });
    }public void addcanvas(MouseEvent e) {
    if (e.getModifiers() == MouseEvent.BUTTON3_MASK) {
      canvas can = new canvas();
      this.add(can);
      can.setBounds(e.getX(), e.getY(), width, height);
      this.validate();
      curCom = can;
    }
    }public void removecanvas(KeyEvent e) {
    this.remove(this.curCom);
    this.validate();
    this.repaint();
    }class canvas extends Canvas {
    public canvas() {
    super();
    this.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        ((applet6)((canvas)e.getSource()).getParent()).curCom=(canvas)e.getSource();
      }
    });
    this.addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent e) {
        ((applet6)((canvas)e.getSource()).getParent()).removecanvas(e);
      }
    });
    }public void paint(Graphics g) {
    g.drawImage(img1,0,0,this);
    }
    }
    }