163 }
164 return true;
165 }
166 } else if (doRestoreFocus(toFocus, vetoedComponent, false)) {
167 return true;
168 }
169 }
170 if (clearOnFailure) {
171 clearGlobalFocusOwnerPriv();
172 return true;
173 } else {
174 return false;
175 }
176 }
177 private boolean restoreFocus(Component toFocus, boolean clearOnFailure) {
178 return doRestoreFocus(toFocus, null, clearOnFailure);
179 }
180 private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
181 boolean clearOnFailure)
182 {
183 if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
184 toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
185 {
186 return true;
187 } else {
188 Component nextFocus = toFocus.getNextFocusCandidate();
189 if (nextFocus != null && nextFocus != vetoedComponent &&
190 nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
191 {
192 return true;
193 } else if (clearOnFailure) {
194 clearGlobalFocusOwnerPriv();
195 return true;
196 } else {
197 return false;
198 }
199 }
200 }
201
202 /**
203 * A special type of SentEvent which updates a counter in the target
204 * KeyboardFocusManager if it is an instance of
205 * DefaultKeyboardFocusManager.
206 */
207 private static class DefaultKeyboardFocusManagerSentEvent
|
163 }
164 return true;
165 }
166 } else if (doRestoreFocus(toFocus, vetoedComponent, false)) {
167 return true;
168 }
169 }
170 if (clearOnFailure) {
171 clearGlobalFocusOwnerPriv();
172 return true;
173 } else {
174 return false;
175 }
176 }
177 private boolean restoreFocus(Component toFocus, boolean clearOnFailure) {
178 return doRestoreFocus(toFocus, null, clearOnFailure);
179 }
180 private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
181 boolean clearOnFailure)
182 {
183 boolean success = true;
184 if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
185 (success = toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK)))
186 {
187 return true;
188 } else {
189 if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
190 if (toFocus.isShowing() && toFocus.canBeFocusOwner()) {
191 restoreFocusTo = toFocus;
192 return true;
193 }
194 }
195 Component nextFocus = toFocus.getNextFocusCandidate();
196 if (nextFocus != null && nextFocus != vetoedComponent &&
197 nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
198 {
199 return true;
200 } else if (clearOnFailure) {
201 clearGlobalFocusOwnerPriv();
202 return true;
203 } else {
204 return false;
205 }
206 }
207 }
208
209 /**
210 * A special type of SentEvent which updates a counter in the target
211 * KeyboardFocusManager if it is an instance of
212 * DefaultKeyboardFocusManager.
213 */
214 private static class DefaultKeyboardFocusManagerSentEvent
|