Hi rdawes
Thanks for the pointer...
http://javaalmanac.com/egs/javax.swi...errideTab.html
Unfortunately, I do not seem to manage to get this working...
First of all, the snipet of code on javaalmanac would not compile due to the order of declaration and use of nextFocusAction. But that is trivial.
I have created my own component factory that extends DefaultComponentFactory and put this code:
Code:
/* (non-Javadoc)
* @see org.springframework.richclient.factory.DefaultComponentFactory#createTextArea()
*/
@Override
public JTextArea createTextArea() {
final JTextArea textArea = super.createTextArea();
changeTabActions(textArea);
return textArea;
}
/* (non-Javadoc)
* @see org.springframework.richclient.factory.DefaultComponentFactory#createTextArea(int, int)
*/
@Override
public JTextArea createTextArea(int rows, int columns) {
final JTextArea textArea = super.createTextArea(rows, columns);
changeTabActions(textArea);
return textArea;
}
private void changeTabActions(final JComponent textArea) {
if (LOG.isDebugEnabled()) {
LOG.debug("CHANGE TAB ACTIONS.... to textArea " + textArea+" ===========================");
}
// The actions
Action nextFocusAction = new AbstractAction("Move Focus Forwards") {
public void actionPerformed(ActionEvent evt) {
((Component)evt.getSource()).transferFocus();
}
};
Action prevFocusAction = new AbstractAction("Move Focus Backwards") {
public void actionPerformed(ActionEvent evt) {
((Component)evt.getSource()).transferFocusBackward();
}
};
// Add actions
textArea.getActionMap().put(nextFocusAction.getValue(Action.NAME), nextFocusAction);
textArea.getActionMap().put(prevFocusAction.getValue(Action.NAME), prevFocusAction);
}
I can see the code being called when I put a textArea:
Code:
final SwingBindingFactory bindingFactory = (SwingBindingFactory) getBindingFactory();
TableFormBuilder formBuilder = new TableFormBuilder(bindingFactory);
formBuilder.addInScrollPane(bindingFactory.createBoundTextArea("internalComment"), "rowSpan=2");
formBuilder.row();
....
Unfortunately, a TAB is still recorded as a TAB and not a jump to the next component.
Amongst my questions, I fail to see how this snipet from javaalmanac.com links the TAB key stroke to the commands? How does it know that it should call the action rather than capturing the TAB?
Geoffrey, the ctrl-tab works as you mentioned but it is not intuitive.
Any suggestion?
Thanks
Benoit