0

JTable を破棄した後、JInternalFrame にフォーカスを移すという単純な (そうではない?) 問題があります。

//I created a table, set it to visible, gave it focus.
list.dispose(); //I did what I wanted with the table and I dispose of it
screen.setVisible(true); //The screen is already visible. this isn't really needed
//After I closed table, I want the focus return to the screen (JInternalFrame)
screen.setFocusable(true); 
screen.requestFocus();
screen.requestFocusInWindow();
screen.requestFocus(true);
desktopPane.setSelectedFrame(screen);

つまり、どのコンポーネントにフォーカスがあるかを確認すると、画面が返されるという意味で、画面はフォーカスを取得します。しかし、バー(ここでは適切な用語がわかりません)アイコン、タイトル、Xのようなものを含む上部のバーは灰色で、青ではありません.

アクティブに振る舞うだけでなく、JInternalFrame LOOKをアクティブにする方法はありますか?

例: http://nexrem.com/projects/FocusDemo.rar NetBeans でこれをすばやく作成しました。

クリックして screen1 を開きます。開いて集中します。クリックして JTable を開きます。開き、フォーカスがあります。Screen1 がフォーカスを失いました。Esc を押して JInternalFrame を閉じます。閉じますが、screen1にはフォーカスがないようです(少なくとも視覚的には)。2 つの JInternalFrames の間にあるため、フォーカス サイクリングと関係があるのではないかと疑っています...

4

1 に答える 1

3

あなたが探しているscreen.setSelected(true);(私はちょうどあなたのコードで試してみましたが、今は動作します)。

@HFOEの提案に関しては、彼が意図したのは次のようなことをすることでした:

SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        screen.requestFocus();
        screen.requestFocusInWindow();
        screen.requestFocus(true);
    }
});

しかし、これがあなたの状況を改善するかどうかはわかりません。

于 2012-05-31T06:10:23.067 に答える