java - 当从 SWT Eclipse 中的 FileDialog 中选择了不正确的文件扩展名/格式时,我将如何显示错误消息?
问题描述
如果在单击按钮时将不正确的文件格式上传到文本字段,我想添加一条错误消息。当文本字段为空时,我有一条错误消息。任何人都可以为此提出任何建议吗?对于这个特定问题,任何值得查看的文档?任何帮助,将不胜感激。
btnRun.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch(e.type) {
case SWT.Selection:
if(txtFile.getText() == null || txtFile.getText().isEmpty()) {
MessageBox error = new MessageBox(shell, SWT.ERROR_UNSPECIFIED | SWT.OK);
error.setText("Empty txtFile");
// open dialog and await user selection.
error.open();
break;
}
}
}
});
}
解决方案
推荐阅读
- hexo - hexo d 和 hexo deploy -g 不工作
- excel - Shape.Top 和 Shape.Left 问题
- python - 使用 lambda 函数在 Tkinter 右键单击中的分配问题
- terraform-provider-aws - terraform 警告必须使用 splat 语法很烦人
- javascript - 在位于 index.js 的拦截器中使用路由器
- android - 反应原生的 onNavigationStateChange 在 Salesforce 页面上不起作用
- django - 基于连接模型的 Django 过滤器
- java - 是否可以通过 FXML 引用 JavaFX 中的转换器?
- php - 如何将laravel的dockerfile的php-redis添加到kubernetes?
- python - 从外部 git 存储库中读取 python 包