作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 ElementListSelectionDialog .我已经按照示例代码进行操作,但无论出于何种原因,对话框都会显示但没有选项
我的代码:
ElementListSelectionDialog dialog =
new ElementListSelectionDialog(shlSpriteCreator, new LabelProvider());
dialog.setMultipleSelection(false);
dialog.setIgnoreCase(true);
dialog.setAllowDuplicates(true);
dialog.setMessage("Select an AI");
dialog.setTitle("What AI to use?");
dialog.setElements(new String[]{"HELLO","GOODBYE"});
if (dialog.open() == Window.OK) {
aiControllerLocation = (String) dialog.getFirstResult();
}
结果对话框:
我最初使用了一个类数组,但由于它不起作用,我用一个简单的字符串列表代替了,尽管据我所知是使用 LabelProvider类我应该能够使用任何对象,它将通过它的 toString() 表示显示。
最佳答案
这种类型的对话框在 Workbench UI 下正常工作。要正确运行此对话框,您应该使用示例代码
ElementListSelectionDialog dialog =
new ElementListSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), new LabelProvider());
关于java - ElementListSelectionDialog 没有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12126311/
我正在尝试使用 ElementListSelectionDialog .我已经按照示例代码进行操作,但无论出于何种原因,对话框都会显示但没有选项 我的代码: ElementListSelectionD
我是一名优秀的程序员,十分优秀!