swt中,怎么控制鼠标的状态,比如连接数据库,这时正在连接数据库时,我想让鼠标呈另外一种图标,并且此时不能做其他的操作,只有等连接返回结果后才能做其他的操作

抽烟殇肺卟殇心 2010-05-04 09:16:37
swt中,怎么控制鼠标的状态,比如连接数据库,这时正在连接数据库时,我想让鼠标呈另外一种图标,并且此时不能做其他的操作,只有等连接返回结果后才能做其他的操作
我是在Eclipse RCP插件的一个Action中实现这样的功能,请大家分析解答............
...全文
159 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
WuBill 2010-05-05
  • 打赏
  • 举报
回复
没弄过RCP
  • 打赏
  • 举报
回复
1楼,你的这个是不正确的,swing中的Cursor放在SWT中用,肯定会出问题撒。
  • 打赏
  • 举报
回复
window.getShell().setCursor(Cursor.WAIT_CURSOR);,会报错。
  • 打赏
  • 举报
回复
不行,会报错的啊,我也试了,请明示。。。。。
meadking 2010-05-04
  • 打赏
  • 举报
回复

Shell.setCursor(new Cursor(Cursor.WAIT_CURSOR));
  • 打赏
  • 举报
回复
我试了,是可以运行。但是怎么在RCP菜单类XXXAction中用不了呢?
WuBill 2010-05-04
  • 打赏
  • 举报
回复
你新建个空类,把main函数放进去运行一下
import语句如下:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

你的import语句里是不是引了awt的Cursor
WuBill 2010-05-04
  • 打赏
  • 举报
回复
当然是SWT了
  • 打赏
  • 举报
回复
楼上的,不行的哦,请问你那个Cursor是swing的,还是SWT中的?
WuBill 2010-05-04
  • 打赏
  • 举报
回复

public static void main(String[] args) {
Display display = new Display();
final Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = new Shell(display);
shell.open();
final Button b = new Button(shell, 0);
b.setBounds(10, 10, 120, 30);
b.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
b.setCursor(cursor);
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
cursor.dispose();
display.dispose();
}

自己照猫画虎吧,其中Cursor常有:
SWT.CURSOR_ARROW
SWT.CURSOR_WAIT
SWT.CURSOR_CROSS
SWT.CURSOR_APPSTARTING
SWT.CURSOR_HELP
SWT.CURSOR_SIZEALL
SWT.CURSOR_SIZENESW
SWT.CURSOR_SIZENS
SWT.CURSOR_SIZENWSE
SWT.CURSOR_SIZEWE
SWT.CURSOR_SIZEN
SWT.CURSOR_SIZES
SWT.CURSOR_SIZEE
SWT.CURSOR_SIZEW
SWT.CURSOR_SIZENE
SWT.CURSOR_SIZESE
SWT.CURSOR_SIZESW
SWT.CURSOR_SIZENW
SWT.CURSOR_UPARROW
SWT.CURSOR_IBEAM
SWT.CURSOR_NO
SWT.CURSOR_HAND

58,454

社区成员

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

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