gpt4 book ai didi

java - ElementListSelectionDialog 没有元素

转载 作者:搜寻专家 更新时间:2023-11-01 03:26:47 26 4
gpt4 key购买 nike

我正在尝试使用 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();
}

结果对话框:

Dialog with no options to select

我最初使用了一个类数组,但由于它不起作用,我用一个简单的字符串列表代替了,尽管据我所知是使用 LabelProvider类我应该能够使用任何对象,它将通过它的 toString() 表示显示。

最佳答案

这种类型的对话框在 Workbench UI 下正常工作。要正确运行此对话框,您应该使用示例代码

ElementListSelectionDialog dialog = 
new ElementListSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), new LabelProvider());

关于java - ElementListSelectionDialog 没有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12126311/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com