779
780 /**
781 * Called by <code>dispatchEvent</code> if no other
782 * KeyEventDispatcher in the dispatcher chain dispatched the KeyEvent, or
783 * if no other KeyEventDispatchers are registered. If the event has not
784 * been consumed, its target is enabled, and the focus owner is not null,
785 * this method dispatches the event to its target. This method will also
786 * subsequently dispatch the event to all registered
787 * KeyEventPostProcessors. After all this operations are finished,
788 * the event is passed to peers for processing.
789 * <p>
790 * In all cases, this method returns <code>true</code>, since
791 * DefaultKeyboardFocusManager is designed so that neither
792 * <code>dispatchEvent</code>, nor the AWT event dispatcher, should take
793 * further action on the event in any situation.
794 *
795 * @param e the KeyEvent to be dispatched
796 * @return <code>true</code>
797 * @see Component#dispatchEvent
798 */
799 public boolean dispatchKeyEvent(KeyEvent e) {
800 Component focusOwner = (((AWTEvent)e).isPosted) ? getFocusOwner() : e.getComponent();
801
802 if (focusOwner != null && focusOwner.isShowing() && focusOwner.canBeFocusOwner()) {
803 if (!e.isConsumed()) {
804 Component comp = e.getComponent();
805 if (comp != null && comp.isEnabled()) {
806 redispatchEvent(comp, e);
807 }
808 }
809 }
810 boolean stopPostProcessing = false;
811 java.util.List<KeyEventPostProcessor> processors = getKeyEventPostProcessors();
812 if (processors != null) {
813 for (java.util.Iterator<KeyEventPostProcessor> iter = processors.iterator();
814 !stopPostProcessing && iter.hasNext(); )
815 {
816 stopPostProcessing = iter.next().
817 postProcessKeyEvent(e);
818 }
1004 */
1005 private boolean hasMarker(Component comp) {
1006 for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
1007 if (iter.next().untilFocused == comp) {
1008 return true;
1009 }
1010 }
1011 return false;
1012 }
1013
1014 /**
1015 * Clears markers queue
1016 * @since 1.5
1017 */
1018 void clearMarkers() {
1019 synchronized(this) {
1020 typeAheadMarkers.clear();
1021 }
1022 }
1023
1024 private boolean preDispatchKeyEvent(KeyEvent ke) {
1025 if (((AWTEvent) ke).isPosted) {
1026 Component focusOwner = getFocusOwner();
1027 ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
1028 }
1029 if (ke.getSource() == null) {
1030 return true;
1031 }
1032
1033 // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
1034 // - A key event is anyway passed to this method which starts its actual dispatching.
1035 // - If a key event is put to the type ahead queue, its time stamp should not be registered
1036 // until its dispatching actually starts (by this method).
1037 EventQueue.setCurrentEventAndMostRecentTime(ke);
1038
1039 /**
1040 * Fix for 4495473.
1041 * This fix allows to correctly dispatch events when native
1042 * event proxying mechanism is active.
1043 * If it is active we should redispatch key events after
|
779
780 /**
781 * Called by <code>dispatchEvent</code> if no other
782 * KeyEventDispatcher in the dispatcher chain dispatched the KeyEvent, or
783 * if no other KeyEventDispatchers are registered. If the event has not
784 * been consumed, its target is enabled, and the focus owner is not null,
785 * this method dispatches the event to its target. This method will also
786 * subsequently dispatch the event to all registered
787 * KeyEventPostProcessors. After all this operations are finished,
788 * the event is passed to peers for processing.
789 * <p>
790 * In all cases, this method returns <code>true</code>, since
791 * DefaultKeyboardFocusManager is designed so that neither
792 * <code>dispatchEvent</code>, nor the AWT event dispatcher, should take
793 * further action on the event in any situation.
794 *
795 * @param e the KeyEvent to be dispatched
796 * @return <code>true</code>
797 * @see Component#dispatchEvent
798 */
799 @SuppressWarnings("deprecation")
800 public boolean dispatchKeyEvent(KeyEvent e) {
801 Component focusOwner = (((AWTEvent)e).isPosted) ? getFocusOwner() : e.getComponent();
802
803 if (focusOwner != null && focusOwner.isShowing() && focusOwner.canBeFocusOwner()) {
804 if (!e.isConsumed()) {
805 Component comp = e.getComponent();
806 if (comp != null && comp.isEnabled()) {
807 redispatchEvent(comp, e);
808 }
809 }
810 }
811 boolean stopPostProcessing = false;
812 java.util.List<KeyEventPostProcessor> processors = getKeyEventPostProcessors();
813 if (processors != null) {
814 for (java.util.Iterator<KeyEventPostProcessor> iter = processors.iterator();
815 !stopPostProcessing && iter.hasNext(); )
816 {
817 stopPostProcessing = iter.next().
818 postProcessKeyEvent(e);
819 }
1005 */
1006 private boolean hasMarker(Component comp) {
1007 for (Iterator<TypeAheadMarker> iter = typeAheadMarkers.iterator(); iter.hasNext(); ) {
1008 if (iter.next().untilFocused == comp) {
1009 return true;
1010 }
1011 }
1012 return false;
1013 }
1014
1015 /**
1016 * Clears markers queue
1017 * @since 1.5
1018 */
1019 void clearMarkers() {
1020 synchronized(this) {
1021 typeAheadMarkers.clear();
1022 }
1023 }
1024
1025 @SuppressWarnings("deprecation")
1026 private boolean preDispatchKeyEvent(KeyEvent ke) {
1027 if (((AWTEvent) ke).isPosted) {
1028 Component focusOwner = getFocusOwner();
1029 ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
1030 }
1031 if (ke.getSource() == null) {
1032 return true;
1033 }
1034
1035 // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
1036 // - A key event is anyway passed to this method which starts its actual dispatching.
1037 // - If a key event is put to the type ahead queue, its time stamp should not be registered
1038 // until its dispatching actually starts (by this method).
1039 EventQueue.setCurrentEventAndMostRecentTime(ke);
1040
1041 /**
1042 * Fix for 4495473.
1043 * This fix allows to correctly dispatch events when native
1044 * event proxying mechanism is active.
1045 * If it is active we should redispatch key events after
|