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

Method setCurrent

CodenameOne/src/com/codename1/ui/Display.java:1540–1675  ·  view source on GitHub ↗
(final Form newForm, boolean reverse)

Source from the content-addressed store, hash-verified

1538 ///
1539 /// - `newForm`: the Form to Display
1540 void setCurrent(final Form newForm, boolean reverse) {
1541 if (edt == null) {
1542 throw new IllegalStateException("Initialize must be invoked before setCurrent!");
1543 }
1544
1545 if (!isEdt()) {
1546 // when not running callSerially executes synchronously and would recurse here forever (#4811)
1547 if (!codenameOneRunning) {
1548 throw new IllegalStateException("Display.setCurrent must be invoked after Codename One has started running. Call it from start() or via callSerially.");
1549 }
1550 callSerially(new RunnableWrapper(newForm, null, reverse));
1551 return;
1552 }
1553
1554 Form current = impl.getCurrentForm();
1555
1556 if (autoFoldVKBOnFormSwitch && !(newForm instanceof Dialog)) {
1557 setShowVirtualKeyboard(false);
1558 }
1559
1560 if (current == newForm) { //NOPMD CompareObjectsWithEquals
1561 current.revalidate();
1562 current.repaint();
1563 current.onShowCompletedImpl();
1564 return;
1565 }
1566
1567 if (impl.isEditingText()) {
1568 switch (showDuringEdit) {
1569 case SHOW_DURING_EDIT_ALLOW_DISCARD:
1570 break;
1571 case SHOW_DURING_EDIT_ALLOW_SAVE:
1572 impl.saveTextEditingState();
1573 break;
1574 case SHOW_DURING_EDIT_EXCEPTION:
1575 throw new IllegalStateException("Show during edit");
1576 case SHOW_DURING_EDIT_IGNORE:
1577 return;
1578 case SHOW_DURING_EDIT_SET_AS_NEXT:
1579 impl.setCurrentForm(newForm);
1580 return;
1581 default:
1582 break;
1583 }
1584 }
1585
1586 if (current != null) {
1587 if (current.isInitialized()) {
1588 current.deinitializeImpl();
1589 } else {
1590 Form fg = getCurrentUpcoming();
1591 if (fg != current) { //NOPMD CompareObjectsWithEquals
1592 if (fg.isInitialized()) {
1593 fg.deinitializeImpl();
1594 }
1595 }
1596 }
1597 }

Callers

nothing calls this directly

Calls 15

isEdtMethod · 0.95
callSeriallyMethod · 0.95
repaintMethod · 0.95
onShowCompletedImplMethod · 0.95
setCurrentFormMethod · 0.95
deinitializeImplMethod · 0.95
getCurrentUpcomingMethod · 0.95
getDisplayWidthMethod · 0.95
getDisplayHeightMethod · 0.95
isMenuMethod · 0.95

Tested by

no test coverage detected