SWT对话框属性详解
来源:互联网 发布:淘宝劲舞团 编辑:程序博客网 时间:2024/06/01 08:14
对话框,都继承自org.eclipse.swt.widgets.Dialog,有Modal的和Modeless的区分,一般的对话框处理程序如下:
<DialogType> dlg = new <DialogType>(shell);
dlg.setSomeData(data);
<ReturnType> returnValue = dlg.open();
if (returnValue == null) {
// User clicked cancel
} else {
// Do something with returnValue
}
对话框主要有以下六种:
1、MessageBox,消息对话框
可定制的对话框样式包括:
标题栏:setText()
消息提示:setMessage()
消息图标类型:style属性,有:SWT.ICON_ERROR,SWT.ICON_INFORMATION,SWT.ICON_QUESTION,SWT.ICON_WARNING,SWT.ICON_WORKING
按钮类型:style属性,有:SWT.OK,SWT.OK | SWT.CANCEL,SWT.YES | SWT.NO,SWT.YES | SWT.NO | SWT.CANCEL,SWT.RETRY | SWT.CANCEL,SWT.ABORT | SWT.RETRY | SWT.IGNORE
对话框返回值:int open(),返回的是点击的按钮对应的int值。
示例:
MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION |SWT.YES | SWT.NO);
messageBox.setMessage(”Is this question simple?”);
int rc = messageBox.open();
2、ColorDialog,选择颜色对话框
ColorDialog dlg = new ColorDialog(shell);
RGB rgb = dlg.open();
if (rgb != null) {
Color color = new Color(shell.getDisplay(), rgb);
}
3、DirectoryDialog,文件夹选择对话框
DirectoryDialog dlg = new DirectoryDialog(shell);
dlg.setFilterPath(text.getText());
dlg.setText(”SWT’s DirectoryDialog”);
dlg.setMessage(”Select a directory”);
String selectedDirectory = dlg.open();
4、FileDialog,文件选择对话框
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
String fileName = dlg.open();
if (fileName != null) {
// Open the file
}
对话框标题栏:void setText(String text)
文件后缀名过滤:void setFilterExtensions (String[] extensions)
缺省路径及文件名:void setFilterPath(String string)
返回值:String[] getFileNames() / String getFileName()
5、FontDial
- SWT对话框属性详解
- SWT对话框属性设置
- SWT对话框自动关闭
- SWT常用系统对话框
- Swt MessageBox 对话框
- SWT打开对话框
- SWT保存对话框
- Java代码 swt对话框
- SWT/JFace的对话框
- Java SWT/JFace对话框
- SWT的MessageBox对话框
- Java代码 swt对话框
- Swt弹出式对话框
- swt中的对话框
- SWT的对话框们
- SWT窗体属性设置
- SWT / JFace 对话框 (转)
- SWT 消息提示框 对话框
- 【linux】ubuntu11.10下各种问题以及解决方案
- 有关游戏的部署方案总结
- 修改图片上的文字步骤
- 根据数据决定选择那个checkbox
- 有关游戏的部署方案总结(二)
- SWT对话框属性详解
- Hibernate 批量插入、更新与删除
- 程序常用日志文件写入函数
- Android 绑定类型服务---简介
- SP2-1503: 无法初始化 Oracle 调用界面 SP2-1503: 无法初始化 Oracle 问题
- 有关游戏的部署方案总结(三)
- dom访问方法
- mysql
- 手机TF 卡 无法读取,提示需要格式化