swt 画图、鼠标拖动问题

dugulindi 2007-12-04 03:07:04
最近想用SWT来写一个画图程序,可是看了SWT的API没找到鼠标拖动的接口,想问SWT中怎样实现鼠标拖动
还有一个就是swt中,画图时和AWT中的paint(griphics g)与repaint()相似的函数是什么?
...全文
376 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yixiliuyun 2008-05-30
  • 打赏
  • 举报
回复
拖动时如果屏幕不重绘就是实现了鼠标拖动的效果, 例如画一条直线
重绘就是那一个点一直跟着鼠标走
dracularking 2008-05-29
  • 打赏
  • 举报
回复
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();
}
gloomyfish 2008-05-24
  • 打赏
  • 举报
回复
在你的applicationworkbenchadvisor里面添加DropTarget对象然后DropTargetAdapter() {
public void drop(DropTargetEvent event) {
// add your codes....
}
}

这个是在RCP plugIn的里面完成调用就好!

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧