TC的handler类调用swt窗口
来源:互联网 发布:努尔哈赤知乎 编辑:程序博客网 时间:2024/05/29 10:10
public class SampleHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
//方法一:新建一个application window的display类,在该类实现对话框功能,直接调用open()
MyDisplay display = new MyDisplay();
display.start();
//方法二:创建一个shell,把实现了功能的对话框dialog加入shell
Shell shell = new Shell();
Dialog2 dialog = new Dialog2(shell, SWT.NONE);
dialog.open();
return null;
}
}
//给按钮添加一个鼠标监听事件,有两种方式实现:
方法一:// button.addListener(SWT.MouseUp, new MouseListener(text));//button.addListener(eventType, listener);//定义一个监听类,然后把自定义的监听类对象传给button的addListener(),enventType定义了button发生listener事件的条件。
class MouseListener implements Listener{
private Text text; public MouseListener(Text text) { this.text = text; } public void handleEvent(Event arg0) { if(text.getText()==null) { MessageBox.post("please input folder-name", "提示:", MessageBox.ERROR); } else { TCSession session = (TCSession) AIFUtility.getDefaultSession(); TCComponentFolderType foldertype; try { InterfaceAIFComponent target = AIFUtility.getTargetComponent(); foldertype = (TCComponentFolderType) session.getTypeComponent("Folder"); TCComponentFolder folder = foldertype.create(text.getText(), "create a folder", "Folder"); if(target instanceof TCComponentFolder){ ((TCComponentFolder) target).add("contents", folder); } } catch (TCException e1) { e1.printStackTrace(); } } }}
//方法二:添加addMouseListener()监听事件,并定义mouseUp(event)执行的操作
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
if(text.getText()==null)
{
MessageBox.post(“please input folder-name”, “提示:”, MessageBox.ERROR);
}
else
{
TCSession session = (TCSession) AIFUtility.getDefaultSession();
TCComponentFolderType foldertype;
try
{
MessageBox.post(“please ….”, “提示:”, MessageBox.ERROR);
foldertype = (TCComponentFolderType) session.getTypeComponent(“Folder”);
TCComponentFolder folder = foldertype.create(text.getText(), “create a folder”, “Folder”);
}
catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
FormData fd_button = new FormData();
fd_button.top = new FormAttachment(0, 5);
fd_button.left = new FormAttachment(0, 157);
button.setLayoutData(fd_button);
button.setText(“\u786E\u5B9A”);
}
- TC的handler类调用swt窗口
- 启动TC的TAO窗口
- SWT下一個簡單的倒計時窗口
- SWT窗口居中的设置
- SWT/Jface 窗口的样式
- 拖动无标栏的SWT窗口
- XP环境下的tc鼠标调用
- Eclipse的SWT窗口布局经验
- SWT无标题栏窗口的拖动
- SWT无标题栏的窗口移动
- 【原创】swing 按钮点击 调用swt窗口(SWT浏览器)browser
- TC脚本开发-窗口句柄的捕捉方法总结
- 通过Java SWT调用操作系统的信息
- TC 2.0 调用汇编
- XP环境下的tc鼠标调用(效果很好)
- 在其他类中调用 swt table
- swt创建不规则窗口
- SWT窗口预览
- Eclipse常用快捷键
- Java Web知识结构
- tensorflow读取数据之CSV格式
- Codeforces Round #358D. Alyona and Strings【DP】
- linux系统redis服务配置
- TC的handler类调用swt窗口
- OZ工具安装使用
- pojlainxi
- 态度
- NFC数据串口传输模块(NFC2COM)--风火轮
- Ajax异步请求
- tomcat启动不了报错: Publishing failed Could not publish to the server. java.lang.IndexOutOfBoundsException
- Spring@Autowired注解与自动装配
- php mongodb操作类,适合mongodb2.x和mongodb3.x