0

在嵌入式框架内使用 JComboBox 时,我确实遇到了一个奇怪的焦点问题。

我创建了一个新的Shell

shell = new Shell(display.getActiveShell(), SWT.SHELL_TRIM | SWT.APPLICATION_MODAL);

我用来创建嵌入式框架的外壳,例如

    Composite contentComposite = new Composite(parent, SWT.EMBEDDED);
    contentComposite.setLayout(new FillLayout());

    frame = SWT_AWT.new_Frame(contentComposite);
    rootPanel = new Panel();
    rootPanel.setLayout(new BorderLayout());
    frame.add(rootPanel);

我在 rootPanel 中添加了一个 JComboBox(有 2 个元素)。当我选择组合框打开下拉菜单时,我可以拖放外壳窗口,而不会失去组合框中的焦点。

当 shell 窗口移动到另一个屏幕区域时,下拉菜单仍然在屏幕上的相同位置。下拉菜单不再显示在组合框下方。

我尝试为某些组件添加焦点侦听器,但焦点不会在组合框上丢失,也不会在外壳上获得。

那么,当外壳移动或获得焦点时,我如何隐藏组合框的弹出窗口。

4

1 回答 1

1

Andrew Thompson在他的评论中描述了 3 个不同的 UI 库不是最佳选择之后,我开始尝试 AWT Choice类。

These class is losing the focus, when the shell window is selected.

所以看起来,在嵌入式 AWT 对象中不能那么容易地使用摆动,但我还没有看到原因。

于 2012-06-12T06:32:57.530 回答