0

RCP アプリケーションでビューの機能を実装CTRL+Fしています (SWT ウィジェットを使用)。そのために、CTRL+F を押すたびに、ビューで入力および検索するための小さなテキスト ボックスがポップアップ表示されます。

しかし、何も入力しないか、他に何もフォーカスしないと、ポップアップしたままになります。

5秒だけ表示したい。それで、誰か助けてください。

前もって感謝します!

より明確にするためにコードを追加します:-

final Text findTextBox = new Text(viewer.getTable(), SWT.BORDER);
if ((((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'f'))) {
    Rectangle rect = viewer.getTable().getBounds();
    findTextBox.setVisible(true);
    findTextBox.setFocus();
        findtextBox.setLocation(rect.x + rect.width -120, rect.y + rect.height - 25);
        findTextBox.setSize(120, 25);
    }
4

1 に答える 1

2

以下は、基本的な Java ライブラリと SWT のみを使用するコードです。

public static void main(String[] args)
{
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final Text text = new Text(shell, SWT.BORDER);
    text.setVisible(false);

    final Runnable timer = new Runnable()
    {
        public void run()
        {
            if (text.isDisposed())
                return;

            text.setVisible(true);
        }
    };

    display.timerExec(5000, timer);

    shell.pack();
    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed())
    {
        if (!display.readAndDispatch())
        {
            display.sleep();
        }
    }
    display.dispose();
}
于 2013-10-01T13:01:24.830 に答える