MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / setFocused

Method setFocused

CodenameOne/src/com/codename1/ui/Form.java:3024–3053  ·  view source on GitHub ↗
(Component focused)

Source from the content-addressed store, hash-verified

3022 ///
3023 /// - `focused`: the newly focused component or null for no focus
3024 public void setFocused(Component focused) {
3025 if (this.focused == focused && focused != null) { //NOPMD CompareObjectsWithEquals
3026 this.focused.repaint();
3027 return;
3028 }
3029 Component oldFocus = this.focused;
3030 this.focused = focused;
3031 boolean triggerRevalidate = false;
3032 if (oldFocus != null) {
3033 triggerRevalidate = changeFocusState(oldFocus, false);
3034 //if we need to revalidate no need to repaint the Component, it will
3035 //be painted from the Form
3036 if (!triggerRevalidate && oldFocus.getParent() != null) {
3037 oldFocus.repaint();
3038 }
3039 }
3040 // a listener might trigger a focus change event essentially
3041 // invalidating focus so we shouldn't break that
3042 if (focused != null && this.focused == focused) { //NOPMD CompareObjectsWithEquals
3043 triggerRevalidate = changeFocusState(focused, true) || triggerRevalidate;
3044 //if we need to revalidate no need to repaint the Component, it will
3045 //be painted from the Form
3046 if (!triggerRevalidate) {
3047 focused.repaint();
3048 }
3049 }
3050 if (triggerRevalidate) {
3051 revalidateLater();
3052 }
3053 }
3054
3055 /// {@inheritDoc}
3056 @Override

Callers 11

setFocusedEditingTextMethod · 0.95
initFocusedMethod · 0.95
pointerPressedMethod · 0.95
pointerDraggedMethod · 0.95
pointerHoverPressedMethod · 0.95
pointerHoverMethod · 0.95
pointerReleasedMethod · 0.95
updateFocusMethod · 0.95
requestFocusMethod · 0.95
removeAllMethod · 0.95
pointerPressedMethod · 0.95

Calls 5

changeFocusStateMethod · 0.95
getParentMethod · 0.95
repaintMethod · 0.95
revalidateLaterMethod · 0.95
repaintMethod · 0.65

Tested by

no test coverage detected