Index: javax/swing/plaf/basic/BasicLookAndFeel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,v retrieving revision 1.44 diff -u -r1.44 BasicLookAndFeel.java --- javax/swing/plaf/basic/BasicLookAndFeel.java 12 Aug 2005 20:45:17 -0000 1.44 +++ javax/swing/plaf/basic/BasicLookAndFeel.java 16 Aug 2005 17:38:20 -0000 @@ -887,7 +887,7 @@ "shift KP_LEFT", "selectPreviousColumnExtendSelection", "ESCAPE", "cancel", "ctrl shift PAGE_UP", "scrollLeftExtendSelection", - "shift KP_RIGHT", " selectNextColumnExtendSelection", + "shift KP_RIGHT", "selectNextColumnExtendSelection", "ctrl PAGE_UP", "scrollLeftChangeSelection", "shift PAGE_UP", "scrollUpExtendSelection", "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", Index: javax/swing/plaf/basic/BasicTableUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v retrieving revision 1.22 diff -u -r1.22 BasicTableUI.java --- javax/swing/plaf/basic/BasicTableUI.java 15 Aug 2005 19:50:38 -0000 1.22 +++ javax/swing/plaf/basic/BasicTableUI.java 16 Aug 2005 17:38:20 -0000 @@ -54,6 +54,7 @@ import java.awt.event.MouseEvent; import javax.swing.AbstractAction; +import javax.swing.ActionMap; import javax.swing.BorderFactory; import javax.swing.CellRendererPane; import javax.swing.InputMap; @@ -68,6 +69,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.InputMapUIResource; import javax.swing.plaf.TableUI; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; @@ -269,23 +271,70 @@ { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); + InputMapUIResource parentInputMap = new InputMapUIResource(); + // FIXME: The JDK uses a LazyActionMap for parentActionMap + ActionMap parentActionMap = new ActionMap(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); - // Register the key bindings with the JTable. + // Register key bindings in the UI InputMap-ActionMap pair // Note that we register key bindings with both the old and new modifier // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. for (int i = 0; i < keys.length; i++) { - table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]), - KeyStroke.getKeyStroke - (((KeyStroke)keys[i]).getKeyCode(), convertModifiers(((KeyStroke)keys[i]).getModifiers())), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - - table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]), - KeyStroke.getKeyStroke - (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + parentInputMap.put(KeyStroke.getKeyStroke + (((KeyStroke)keys[i]).getKeyCode(), convertModifiers + (((KeyStroke)keys[i]).getModifiers())), + (String)ancestorMap.get((KeyStroke)keys[i])); + + parentInputMap.put(KeyStroke.getKeyStroke + (((KeyStroke)keys[i]).getKeyCode(), + ((KeyStroke)keys[i]).getModifiers()), + (String)ancestorMap.get((KeyStroke)keys[i])); + + parentActionMap.put + ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy + (action, (String)ancestorMap.get((KeyStroke)keys[i]))); + } + // Set the UI InputMap-ActionMap pair to be the parents of the + // JTable's InputMap-ActionMap pair + parentInputMap.setParent + (table.getInputMap + (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); + parentActionMap.setParent(table.getActionMap().getParent()); + table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). + setParent(parentInputMap); + table.getActionMap().setParent(parentActionMap); + } + + /** + * This class is used to mimmic the behaviour of the JDK when registering + * keyboard actions. It is the same as the private class used in JComponent + * for the same reason. This class receives an action event and dispatches + * it to the true receiver after altering the actionCommand property of the + * event. + */ + private static class ActionListenerProxy + extends AbstractAction + { + TableAction target; + String bindingCommandName; + + public ActionListenerProxy(TableAction li, + String cmd) + { + target = li; + bindingCommandName = cmd; + } + + public void actionPerformed(ActionEvent e) + { + ActionEvent derivedEvent = new ActionEvent(e.getSource(), + e.getID(), + bindingCommandName, + e.getModifiers()); + target.actionPerformed(derivedEvent); + } } /**