412 rootPane.disableTrueDoubleBuffering();
413 }
414 }
415 }
416
417
418 /**
419 * Returns true if {@code c} is the component the graphics is being
420 * requested of. This is intended for use when getGraphics is invoked.
421 */
422 private static boolean isComponentObtainingGraphicsFrom(Component c) {
423 synchronized(componentObtainingGraphicsFromLock) {
424 return (componentObtainingGraphicsFrom == c);
425 }
426 }
427
428 /**
429 * Returns the Set of <code>KeyStroke</code>s to use if the component
430 * is managing focus for forward focus traversal.
431 */
432 static Set<KeyStroke> getManagingFocusForwardTraversalKeys() {
433 synchronized(JComponent.class) {
434 if (managingFocusForwardTraversalKeys == null) {
435 managingFocusForwardTraversalKeys = new HashSet<KeyStroke>(1);
436 managingFocusForwardTraversalKeys.add(
437 KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
438 InputEvent.CTRL_MASK));
439 }
440 }
441 return managingFocusForwardTraversalKeys;
442 }
443
444 /**
445 * Returns the Set of <code>KeyStroke</code>s to use if the component
446 * is managing focus for backward focus traversal.
447 */
448 static Set<KeyStroke> getManagingFocusBackwardTraversalKeys() {
449 synchronized(JComponent.class) {
450 if (managingFocusBackwardTraversalKeys == null) {
451 managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>(1);
452 managingFocusBackwardTraversalKeys.add(
453 KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
454 InputEvent.SHIFT_MASK |
455 InputEvent.CTRL_MASK));
456 }
457 }
458 return managingFocusBackwardTraversalKeys;
459 }
460
461 private static Rectangle fetchRectangle() {
462 synchronized(tempRectangles) {
463 Rectangle rect;
464 int size = tempRectangles.size();
465 if (size > 0) {
466 rect = tempRectangles.remove(size - 1);
467 }
2869 * of the <code>KeyEvent</code> <code>e</code>. This obtains
2870 * the appropriate <code>InputMap</code>,
2871 * gets the binding, gets the action from the <code>ActionMap</code>,
2872 * and then (if the action is found and the component
2873 * is enabled) invokes <code>notifyAction</code> to notify the action.
2874 *
2875 * @param ks the <code>KeyStroke</code> queried
2876 * @param e the <code>KeyEvent</code>
2877 * @param condition one of the following values:
2878 * <ul>
2879 * <li>JComponent.WHEN_FOCUSED
2880 * <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
2881 * <li>JComponent.WHEN_IN_FOCUSED_WINDOW
2882 * </ul>
2883 * @param pressed true if the key is pressed
2884 * @return true if there was a binding to an action, and the action
2885 * was enabled
2886 *
2887 * @since 1.3
2888 */
2889 protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
2890 int condition, boolean pressed) {
2891 InputMap map = getInputMap(condition, false);
2892 ActionMap am = getActionMap(false);
2893
2894 if(map != null && am != null && isEnabled()) {
2895 Object binding = map.get(ks);
2896 Action action = (binding == null) ? null : am.get(binding);
2897 if (action != null) {
2898 return SwingUtilities.notifyAction(action, ks, e, this,
2899 e.getModifiers());
2900 }
2901 }
2902 return false;
2903 }
2904
2905 /**
2906 * This is invoked as the result of a <code>KeyEvent</code>
2907 * that was not consumed by the <code>FocusManager</code>,
2908 * <code>KeyListeners</code>, or the component. It will first try
|
412 rootPane.disableTrueDoubleBuffering();
413 }
414 }
415 }
416
417
418 /**
419 * Returns true if {@code c} is the component the graphics is being
420 * requested of. This is intended for use when getGraphics is invoked.
421 */
422 private static boolean isComponentObtainingGraphicsFrom(Component c) {
423 synchronized(componentObtainingGraphicsFromLock) {
424 return (componentObtainingGraphicsFrom == c);
425 }
426 }
427
428 /**
429 * Returns the Set of <code>KeyStroke</code>s to use if the component
430 * is managing focus for forward focus traversal.
431 */
432 @SuppressWarnings("deprecation")
433 static Set<KeyStroke> getManagingFocusForwardTraversalKeys() {
434 synchronized(JComponent.class) {
435 if (managingFocusForwardTraversalKeys == null) {
436 managingFocusForwardTraversalKeys = new HashSet<KeyStroke>(1);
437 managingFocusForwardTraversalKeys.add(
438 KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
439 InputEvent.CTRL_MASK));
440 }
441 }
442 return managingFocusForwardTraversalKeys;
443 }
444
445 /**
446 * Returns the Set of <code>KeyStroke</code>s to use if the component
447 * is managing focus for backward focus traversal.
448 */
449 @SuppressWarnings("deprecation")
450 static Set<KeyStroke> getManagingFocusBackwardTraversalKeys() {
451 synchronized(JComponent.class) {
452 if (managingFocusBackwardTraversalKeys == null) {
453 managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>(1);
454 managingFocusBackwardTraversalKeys.add(
455 KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
456 InputEvent.SHIFT_MASK |
457 InputEvent.CTRL_MASK));
458 }
459 }
460 return managingFocusBackwardTraversalKeys;
461 }
462
463 private static Rectangle fetchRectangle() {
464 synchronized(tempRectangles) {
465 Rectangle rect;
466 int size = tempRectangles.size();
467 if (size > 0) {
468 rect = tempRectangles.remove(size - 1);
469 }
2871 * of the <code>KeyEvent</code> <code>e</code>. This obtains
2872 * the appropriate <code>InputMap</code>,
2873 * gets the binding, gets the action from the <code>ActionMap</code>,
2874 * and then (if the action is found and the component
2875 * is enabled) invokes <code>notifyAction</code> to notify the action.
2876 *
2877 * @param ks the <code>KeyStroke</code> queried
2878 * @param e the <code>KeyEvent</code>
2879 * @param condition one of the following values:
2880 * <ul>
2881 * <li>JComponent.WHEN_FOCUSED
2882 * <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
2883 * <li>JComponent.WHEN_IN_FOCUSED_WINDOW
2884 * </ul>
2885 * @param pressed true if the key is pressed
2886 * @return true if there was a binding to an action, and the action
2887 * was enabled
2888 *
2889 * @since 1.3
2890 */
2891 @SuppressWarnings("deprecation")
2892 protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
2893 int condition, boolean pressed) {
2894 InputMap map = getInputMap(condition, false);
2895 ActionMap am = getActionMap(false);
2896
2897 if(map != null && am != null && isEnabled()) {
2898 Object binding = map.get(ks);
2899 Action action = (binding == null) ? null : am.get(binding);
2900 if (action != null) {
2901 return SwingUtilities.notifyAction(action, ks, e, this,
2902 e.getModifiers());
2903 }
2904 }
2905 return false;
2906 }
2907
2908 /**
2909 * This is invoked as the result of a <code>KeyEvent</code>
2910 * that was not consumed by the <code>FocusManager</code>,
2911 * <code>KeyListeners</code>, or the component. It will first try
|