From ca1a6e07cd32c8f0c62f66e40c68af80fc40543e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 8 Aug 2006 22:28:54 +0000 Subject: 2006-08-08 Roman Kennke PR 28650 * javax/swing/plaf/basic/BasicMenuBarUI.java (getActionMap): Store ActionMap in MenuBar.actionMap, rather than Tree.actionMap. * javax/swing/plaf/basic/BasicTreeUI.java (action): Removed obsolete field. (uninstallKeyboardActions): Removed action field handling. (installKeyboardActions): Removed action field handling. (createDefaultActions): Don't install removed TreeAction. (TreeAction): Removed obsolete inner class. (ActionListenerProxy): Removed obsolete inner class. (MouseHandler.mousePressed): Request focus on JTree component on mouse press. 2006-08-08 Roman Kennke * javax/swing/plaf/basic/BasicListUI.java (MouseInputHandler.mousePressed): Request focus on list component. 2006-08-08 Roman Kennke * javax/swing/plaf/basic/BasicTableUI.java (MouseInputHandler.mousePressed): Request focus on list component. --- ChangeLog | 28 ++++++++ javax/swing/plaf/basic/BasicListUI.java | 3 +- javax/swing/plaf/basic/BasicMenuBarUI.java | 4 +- javax/swing/plaf/basic/BasicTableUI.java | 3 + javax/swing/plaf/basic/BasicTreeUI.java | 100 +---------------------------- 5 files changed, 38 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 341e8a5cf..ce1de9d97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2006-08-08 Roman Kennke + + PR 28650 + * javax/swing/plaf/basic/BasicMenuBarUI.java + (getActionMap): Store ActionMap in MenuBar.actionMap, rather + than Tree.actionMap. + * javax/swing/plaf/basic/BasicTreeUI.java + (action): Removed obsolete field. + (uninstallKeyboardActions): Removed action field handling. + (installKeyboardActions): Removed action field handling. + (createDefaultActions): Don't install removed TreeAction. + (TreeAction): Removed obsolete inner class. + (ActionListenerProxy): Removed obsolete inner class. + (MouseHandler.mousePressed): Request focus on JTree component + on mouse press. + +2006-08-08 Roman Kennke + + * javax/swing/plaf/basic/BasicListUI.java + (MouseInputHandler.mousePressed): Request focus on list + component. + +2006-08-08 Roman Kennke + + * javax/swing/plaf/basic/BasicTableUI.java + (MouseInputHandler.mousePressed): Request focus on list + component. + 2006-08-08 Roman Kennke * javax/swing/plaf/basic/BasicTextUI.java diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java index e8f398fea..befc22736 100644 --- a/javax/swing/plaf/basic/BasicListUI.java +++ b/javax/swing/plaf/basic/BasicListUI.java @@ -479,7 +479,8 @@ public class BasicListUI extends ListUI */ public void mousePressed(MouseEvent event) { - // TODO: What should be done here, if anything? + // We need to explicitly request focus. + list.requestFocusInWindow(); } /** diff --git a/javax/swing/plaf/basic/BasicMenuBarUI.java b/javax/swing/plaf/basic/BasicMenuBarUI.java index 1a20fc6b1..cd25a3baf 100644 --- a/javax/swing/plaf/basic/BasicMenuBarUI.java +++ b/javax/swing/plaf/basic/BasicMenuBarUI.java @@ -246,11 +246,11 @@ public class BasicMenuBarUI extends MenuBarUI */ private ActionMap getActionMap() { - ActionMap am = (ActionMap) UIManager.get("Tree.actionMap"); + ActionMap am = (ActionMap) UIManager.get("MenuBar.actionMap"); if (am == null) { am = createDefaultActions(); - UIManager.getLookAndFeelDefaults().put("Tree.actionMap", am); + UIManager.getLookAndFeelDefaults().put("MenuBar.actionMap", am); } return am; } diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java index d26f5abdd..15be4d57e 100644 --- a/javax/swing/plaf/basic/BasicTableUI.java +++ b/javax/swing/plaf/basic/BasicTableUI.java @@ -308,6 +308,9 @@ public class BasicTableUI extends TableUI colLead != colModel.getLeadSelectionIndex()) if (table.isEditing()) table.editingStopped(new ChangeEvent(e)); + + // Must request focus explicitly. + table.requestFocusInWindow(); } } diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index c1915567d..f61824bb7 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -238,9 +238,6 @@ public class BasicTreeUI /** Set to true if the editor has a different size than the renderer. */ protected boolean editorHasDifferentSize; - /** The action bound to KeyStrokes. */ - TreeAction action; - /** Boolean to keep track of editing. */ boolean isEditing; @@ -1081,7 +1078,6 @@ public class BasicTreeUI */ protected void uninstallKeyboardActions() { - action = null; tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent( null); tree.getActionMap().setParent(null); @@ -1298,8 +1294,6 @@ public class BasicTreeUI JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, ancestorInputMap); - action = new TreeAction(); - SwingUtilities.replaceUIActionMap(tree, getActionMap()); } @@ -1329,9 +1323,6 @@ public class BasicTreeUI ActionMapUIResource am = new ActionMapUIResource(); Action action; - action = new TreeAction(); - am.put(action.getValue(Action.NAME), action); - // TreeHomeAction. action = new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); @@ -2059,94 +2050,6 @@ public class BasicTreeUI } } - /** - * This class implements the actions that we want to happen when specific keys - * are pressed for the JTree. The actionPerformed method is called when a key - * that has been registered for the JTree is received. - */ - class TreeAction - extends AbstractAction - { - - /** - * What to do when this action is called. - * - * @param e the ActionEvent that caused this action. - */ - public void actionPerformed(ActionEvent e) - { - String command = e.getActionCommand(); - TreePath lead = tree.getLeadSelectionPath(); - - if (command.equals("selectPreviousChangeLead") - || command.equals("selectPreviousExtendSelection") - || command.equals("selectPrevious") || command.equals("selectNext") - || command.equals("selectNextExtendSelection") - || command.equals("selectNextChangeLead")) - (new TreeIncrementAction(0, "")).actionPerformed(e); - else if (command.equals("selectParent") || command.equals("selectChild")) - (new TreeTraverseAction(0, "")).actionPerformed(e); - else if (command.equals("selectAll")) - { - TreePath[] paths = new TreePath[treeState.getRowCount()]; - for (int i = 0; i < paths.length; i++) - paths[i] = treeState.getPathForRow(i); - tree.addSelectionPaths(paths); - } - else if (command.equals("startEditing")) - tree.startEditingAtPath(lead); - else if (command.equals("toggle")) - { - if (tree.isEditing()) - tree.stopEditing(); - else - { - Object last = lead.getLastPathComponent(); - TreePath path = new TreePath(getPathToRoot(last, 0)); - if (! treeModel.isLeaf(last)) - toggleExpandState(path); - } - } - else if (command.equals("clearSelection")) - tree.clearSelection(); - - if (tree.isEditing() && ! command.equals("startEditing")) - tree.stopEditing(); - - tree.scrollPathToVisible(tree.getLeadSelectionPath()); - } - } - - /** - * This class is used to mimic 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 - { - ActionListener target; - - String bindingCommandName; - - public ActionListenerProxy(ActionListener 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); - } - } - /** * Updates the preferred size when scrolling, if necessary. */ @@ -2529,6 +2432,9 @@ public class BasicTreeUI } } } + + // We need to request the focus. + tree.requestFocusInWindow(); } /** -- cgit v1.2.1