0

ここで言及されているのと同じ問題に直面していますSWT: Table lost selection。Windowsではなくubuntu 12.04を使用しています。フォーカスが失われた後でも、SWT テーブルの選択された行を強調表示する方法はありますか? フォーカスリスナーをテーブルに追加しようとしましたが、フォーカスが失われたときに選択したアイテムの背景色を変更し、フォーカスゲインで背景色をリセットしました。コードを参照してください。

        @Override
        public void focusLost(FocusEvent e) {
            System.out.println("table focus los");
            TableItem item = fileListTable
                    .getItem(fileListTable.getSelectionIndex());
            prevSelItemBackground = item.getBackground();
            item.setBackground(soureWindow.getSelectionBackground());//Some random colour
            System.out.println(fileListTable.getSelectionIndex());
        }

        @Override
        public void focusGained(FocusEvent e) {
            System.out.println("table focus gain");
            TableItem item = fileListTable
                    .getItem(fileListTable.getSelectionIndex());
            item.setBackground(prevSelItemBackground);
            System.out.println(fileListTable.getSelectionIndex());
        }

しかし、それは機能していません。これに対する他の解決策/回避策はありますか?

4

1 に答える 1