最近想用SWT来写一个画图程序,可是看了SWT的API没找到鼠标拖动的接口,想问SWT中怎样实现鼠标拖动
还有一个就是swt中,画图时和AWT中的paint(griphics g)与repaint()相似的函数是什么?

解决方案 »

  1.   

    在你的applicationworkbenchadvisor里面添加DropTarget对象然后DropTargetAdapter() {
          public void drop(DropTargetEvent event) {
            // add your codes....
          }
    }这个是在RCP plugIn的里面完成调用就好!
      

  2.   

    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("GCT2");
    final Canvas canvas = new Canvas(shell, SWT.NONE);
    canvas.setBounds(0, 0, 200, 200);
    // shell必须在canvas之后,gc 之前open
    shell.open();
    GC gc = new GC(canvas);
    gc.drawLine(0, 10, 140, 150);
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
    display.sleep();
    }