首页 > 解决方案 > 当从 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;
                            }
                        }
                    }
                });
}

标签: javaeclipseswtmessagebox

解决方案


推荐阅读