Focus problem
I have a JTabbedPane enclosed in a JFrame. One of the tabs is a JPanel on which I am trying to get the use to press the arrow keys to move a cursor.
in order to override the consuming of the keyboard events i have tried to transfer the focus of the wondow to this JPanel whenever that part of the pane is activated.
I have added a FocusListener to the Panel to allow me to see if the focus has been gained or not. It has never been gained by the panel. The code from the JFrame class is below:
tab.addChangeListener(new ChangeListener()
{public void stateChanged(ChangeEvent e)
{
// Check the correct tab was chosen
if (tab.getSelectedIndex() == 2)
{
gPanel.requestFocusInWindow();
}
}
});
'gPanel' is the JPanel which i am trying to use. Within this panel I have altered the key bindings so that once focus has been gained, this panel will accept relevant keyboard input.
Action action = new MyAction("ghost");
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "left");
getActionMap().put("left", action);
...etc
Thanks
Maurice

