public class Dialog

  1. Object
  2. Component
  3. Container
  4. Form
  5. Dialog

ImplementsAbstractDialog, Animation, Editable, Iterable<Component>, StyleListener, TopLevelContainer

Known subtypesProgress

A dialog is a form that occupies a part of the screen and appears as a modal entity to the developer. Dialogs allow us to prompt users for information and rely on the information being available on the next line after the show method.

Modality indicates that a dialog will block the calling thread even if the calling thread is the EDT. Notice that a dialog will not release the block until dispose is called even if show() from another form is called! Events are still performed thanks to the com.codename1.ui.Display#invokeAndBlock(java.lang.Runnable) capability of the Display class.

To determine the size of the dialog use the show method that accepts 4 integer values, notice that these values accept margin from the four sides rather than x, y, width and height values!

It’s important to style a Dialog using Dialog#getDialogStyle() or Dialog#setDialogUIID(java.lang.String) methods rather than styling the dialog object directly.

The Dialog class also includes support for popup dialog which is a dialog type that is positioned next to a component or screen area and points an arrow at that location.

Static Dialog.show(...) APIs can optionally use InteractionDialog under the hood by setting Dialog#setDefaultInteractionDialogMode(boolean) or the theme constant defaultInteractionDialogModeBool.

Typical dialog usage looks like this:

final Button show = new Button("Show Dialog");
final Button showPopup = new Button("Show Popup");
cnt.add(show).add(showPopup);
show.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
        Dialog.show("Dialog Title", "This is the dialog body, it can contain anything...", "OK", "Cancel");
    }
});
showPopup.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
        Dialog d = new Dialog("Popup Title");
        TextArea popupBody = new TextArea("This is the body of the popup", 3, 10);
        popupBody.setUIID("PopupBody");
        popupBody.setEditable(false);
        d.setLayout(new BorderLayout());
        d.add(BorderLayout.CENTER, popupBody);
        d.showPopupDialog(showPopup);
    }
});

See this sample for showing a dialog at the bottom of the screen:

Dialog dlg = new Dialog("At Bottom");
dlg.setLayout(new BorderLayout());
// span label accepts the text and the UIID for the dialog body
dlg.add(new SpanLabel("Dialog Body text", "DialogBody"));
int h = Display.getInstance().getDisplayHeight();
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.show(h /8 * 7, 0, 0, 0);

Fields

public static final int TYPE_NONE = 0Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set
public static final int TYPE_ALARM = 1Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set
public static final int TYPE_CONFIRMATION = 2Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set
public static final int TYPE_ERROR = 3Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set
public static final int TYPE_INFO = 4Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set
public static final int TYPE_WARNING = 5Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

Constructors

public Dialog(String title)Constructs a Dialog with a title
public Dialog(String title, Layout lm)Constructs a Dialog with a title
public Dialog()Constructs a Dialog
public Dialog(Layout lm)Constructs a Dialog with a layout

Methods

public static boolean isDefaultDisposeWhenPointerOutOfBounds()The default pointer out of bounds dispose behavior, notice that this only applies to dialogs and not popup dialogs where this is always true by default
public static void setDefaultDisposeWhenPointerOutOfBounds(boolean aDefaultDisposeWhenPointerOutOfBounds)The default pointer out of bounds dispose behavior, notice that this only applies to dialogs and not popup dialogs where this is always true by default
public static boolean show(String title, String text, int type, Image icon, String okText, String cancelText)Shows a modal prompt dialog with the given title and text.
public static boolean show(String title, String text, int type, Image icon, String okText, String cancelText, long timeout)Shows a modal prompt dialog with the given title and text.
public static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout)Shows a modal prompt dialog with the given title and text.
public static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout)Shows a modal prompt dialog with the given title and text.
public static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout, Transition transition)Shows a modal prompt dialog with the given title and text.
public static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)Shows a modal prompt dialog with the given title and text.
public static boolean show(String title, String text, String okText, String cancelText)Shows a modal prompt dialog with the given title and text.
public static Command show(String title, Component body, Command... cmds)Shows a modal dialog with the given component as its “body” placed in the center.
public static Command show(String title, String body, Command... cmds)Shows a modal dialog with the given component as its “body” placed in the center.
public static Command show(String title, Component body, Command[] cmds, int type, Image icon)Shows a modal dialog with the given component as its “body” placed in the center.
public static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout)Shows a modal dialog with the given component as its “body” placed in the center.
public static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout, Transition transition)Shows a modal dialog with the given component as its “body” placed in the center.
public static Command show(String title, Component body, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)Shows a modal dialog with the given component as its “body” placed in the center.
public static String getDefaultDialogPosition()Default screen orientation position for the upcoming dialog.
public static void setDefaultDialogPosition(String p)Default screen orientation position for the upcoming dialog.
public static int getDefaultDialogType()The default type for dialogs
public static void setDefaultDialogType(int d)The default type for dialogs
public static boolean isAutoAdjustDialogSize()Indicates whether Codename One should try to automatically adjust a showing dialog size when a screen size change event occurs
public static void setAutoAdjustDialogSize(boolean a)Indicates whether Codename One should try to automatically adjust a showing dialog size when a screen size change event occurs
public static boolean isDisableStaticDialogScrolling()Allows a developer to indicate his interest that the dialog should no longer scroll on its own but rather rely on the scrolling properties of internal scrollable containers.
public static void setDisableStaticDialogScrolling(boolean d)Allows a developer to indicate his interest that the dialog should no longer scroll on its own but rather rely on the scrolling properties of internal scrollable containers.
public static boolean isCommandsAsButtons()Places commands as buttons at the bottom of the standard static dialogs rather than as softbuttons.
public static void setCommandsAsButtons(boolean c)Places commands as buttons at the bottom of the standard static dialogs rather than as softbuttons.
public static float getDefaultBlurBackgroundRadius()Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur.
public static void setDefaultBlurBackgroundRadius(float aDefaultBlurBackgroundRadius)Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur.
public static boolean isDefaultTitleCentered()Indicates whether newly-created dialogs place their title in the absolute center, with the body below it.
public static void setDefaultTitleCentered(boolean defaultTitleCentered)Sets whether newly-created Dialog and InteractionDialog instances place their title in the absolute center, with the body below it.
public static boolean isDefaultNativeWindowMode()Whether newly created dialogs are backed by a real operating system window on desktop platforms.
public static void setDefaultNativeWindowMode(boolean nativeWindowMode)Sets whether newly created dialogs are backed by a real operating system window on desktop platforms.
public boolean isNativeWindowMode()Whether this dialog is backed by a real operating system window.
public void setNativeWindowMode(boolean nativeWindowMode)Sets whether this dialog is backed by a real operating system window.
public Window getNativeWindow()The window backing this dialog while it is showing.
protected void initNativeWindow(Window w)Called once the window backing this dialog has been configured and before it is shown, so an application can adjust it – make it resizable, give it an icon, take its decoration away.
public static boolean isDefaultInteractionDialogMode()Indicates whether newly-created dialogs should use InteractionDialog under the hood.
public static void setDefaultInteractionDialogMode(boolean defaultInteractionDialogMode)Indicates whether newly-created dialogs should use InteractionDialog under the hood.
public boolean isInteractionDialogMode()Indicates whether this dialog should use InteractionDialog under the hood.
public void setInteractionDialogMode(boolean interactionDialogMode)Indicates whether this dialog should use InteractionDialog under the hood.
public void setPreviousForm(Form previousForm)When the dialog is disposed this form will show.
protected final void initGlobalToolbar()Overriden to disable the toolbar in dialogs
public Container getContentPane()This method returns the Content pane instance
public Layout getLayout()Returns the layout manager of the form’s content pane.
public final void setLayout(Layout layout)Sets the layout manager responsible for arranging this container
public String getTitle()Returns the Form title text
public final void setTitle(String title)Sets the Form title to the given text
public final void addComponent(Component cmp)Adds Component to the Form’s Content Pane
public void addComponent(Object constraints, Component cmp)Adds a Component to the Container
public void addComponent(int index, Object constraints, Component cmp)Adds a Component to the Container
public void addComponent(int index, Component cmp)Adds Component to the Form’s Content Pane
public void removeAll()Removes all Components from the Content Pane
public void removeComponent(Component cmp)Removes a component from the Form’s Content Pane
public void refreshTheme(boolean merge)Refreshing the theme reinstalls the menu bar, and installing it moves the form’s title component into the title area.
public Label getTitleComponent()Allows modifying the title attributes beyond style (e.g. setting icon/alignment etc.)
public void setTitleComponent(Label title)Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects.
public boolean isTitleCentered()Returns whether this dialog places its title in the absolute center with the body below it.
public void setTitleCentered(boolean titleCentered)Places the title in the absolute center with the body below it.
public Style getTitleStyle()Returns the style of the title
public Container getDialogComponent()Returns the container that actually implements the dialog positioning.
public void setTitleComponent(Label title, Transition t)Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects.
public String getDialogUIID()Returns the uiid of the dialog
public void setDialogUIID(String uiid)Simple setter to set the Dialog uiid
public Style getDialogStyle()Simple getter to get the Dialog Style
public void setDialogStyle(Style style)Simple setter to set the Dialog Style
protected void initLaf(UIManager uim)Initialize the default transition for the dialogs overriding the forms transition
public Command show(int top, int bottom, int left, int right, boolean includeTitle)Deprecated This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
public Command show(int top, int bottom, int left, int right)This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
public Command show(int top, int bottom, int left, int right, boolean includeTitle, boolean modal)Deprecated This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
public Command showAtPosition(int top, int bottom, int left, int right, boolean modal)This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
public void setTimeout(long time)Indicates the time (in milliseconds) afterwhich the dialog will be disposed implicitly
public void setTransitions(Transition transition)Sets in/out transition for dialogs that support transitions.
public void configureCommands(Command[] cmds, boolean commandsAsButtons)Configures commands for the dialog UI.
protected void autoAdjust(int w, int h)Auto adjust size of the dialog.
public void placeButtonCommands(Command[] cmds)Deprecated Places the given commands in the dialog command area, this is very useful for touch devices.
public void keyReleased(int keyCode)If this Component is focused, the key released event will call this method
protected void onShow()Allows subclasses to bind functionality that occurs when a specific form or dialog appears on the screen
public void showBack()Displays the current form on the screen, this version of the method is useful for “back” navigation since it reverses the direction of the transition.
public void setScrollable(boolean scrollable)The equivalent of calling both setScrollableY and setScrollableX
public void show()The default version of show modal shows the dialog occupying the center portion of the screen.
public void showModeless()Shows a modeless dialog which is useful for some simpler use cases such as progress indication etc…
public void setTopLevelHost(TopLevelContainer host)The top level this dialog appears on when it is shown.
public TopLevelContainer getTopLevelHost()Returns the top level set with #setTopLevelHost(TopLevelContainer).
public void addCommand(Command cmd, int offset)Hands menu style commands to the window so the platform can put them wherever it shows a window’s commands.
public void removeCommand(Command cmd)Removes the command from the menu bar softkeys
public void removeAllCommands()Clear menu commands from the menu bar
public Command showPopupDialog(Component c)A popup dialog is shown with the context of a component and its selection, it is disposed seamlessly if the back button is pressed or if the user touches outside its bounds.
public Command showPopupDialog(Rectangle rect)A popup dialog is shown with the context of a component and its selection, it is disposed seamlessly if the back button is pressed or if the user touches outside its bounds.
public Command showPacked(String position, boolean modal)Convenience method to show a dialog sized to match its content.
public Command showStretched(String position, boolean modal)Convenience method to show a dialog stretched to one of the sides
public Command showStetched(String position, boolean modal)Deprecated Convenience method to show a dialog stretched to one of the sides
public Dimension getDialogPreferredSize()Returns the preferred size of the dialog, this allows developers to position a dialog manually in arbitrary positions.
public void dispose()Closes the current form and returns to the previous form, releasing the EDT in the process
public Command showDialog()Shows a modal dialog and returns the command pressed within the modal dialog
protected void actionCommand(Command cmd)Invoked to allow subclasses of form to handle a command from one point rather than implementing many command instances
public boolean animate()Allows the animation to reduce “repaint” calls when it returns false.
public boolean isAutoDispose()Determines whether the execution of a command on this dialog implicitly disposes the dialog.
public final void setAutoDispose(boolean autoDispose)Determines whether the execution of a command on this dialog implicitly disposes the dialog.
public int getDialogType()The type of the dialog can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
public void setDialogType(int dialogType)The type of the dialog can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
public boolean isDisposeWhenPointerOutOfBounds()This flag indicates if the dialog should be disposed if a pointer released event occurred out of the dialog content.
public final void setDisposeWhenPointerOutOfBounds(boolean disposeWhenPointerOutOfBounds)This flag indicates if the dialog should be disposed if a pointer released event occurred out of the dialog content.
public void pointerReleased(int x, int y)If this Component is focused, the pointer released event will call this method
public void pointerPressed(int x, int y)If this Component is focused, the pointer pressed event will call this method
public boolean wasDisposedDueToOutOfBoundsTouch()Returns true if a dialog that was disposed did it because of a pointer out of bounds
public String getDialogPosition()Screen orientation position for the upcoming dialog.
public void setDialogPosition(String dialogPosition)Screen orientation position for the upcoming dialog.
public void growOrShrink()Allows a dialog component to grow or shrink to its new preferred size
public Boolean getPopupDirectionBiasPortrait()Indicates if we want to enforce directional bias for the popup dialog.
public void setPopupDirectionBiasPortrait(Boolean popupDirectionBiasPortrait)Indicates if we want to enforce directional bias for the popup dialog.
public boolean wasDisposedDueToRotation()Returns true if the dialog was disposed automatically due to device rotation
public float getBlurBackgroundRadius()Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur.
public void setBlurBackgroundRadius(float blurBackgroundRadius)Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur.
public void setUIIDByPopupPosition(boolean b)Allows to use the UIIDs “PopupContentPaneDownwards”, “PopupContentPaneUpwards”, “PopupContentPaneRight”, “PopupContentPaneLeft” (instead of the default UIID “PopupContentPane”) to style the PopupDialog more accurately based on the position of the dialog popup compared to the context component.

Inherited nested types

Inherited fields

Inherited methods

From Form

setAllowEnableLayoutOnPaint, addPasteListener, removePasteListener, dispatchPaste, getTextSelection, isEnableCursors, setEnableCursors, getSourceCommand, setSourceCommand, getCurrentInputDevice, setCurrentInputDevice, setOverrideInvisibleAreaUnderVKB, getInvisibleAreaUnderVKB, getAnimationManager, isFormBottomPaddingEditingMode, setFormBottomPaddingEditingMode, getSafeArea, shouldPaintStatusBar, createStatusBar, isAlwaysTensile, setAlwaysTensile, grabAnimationLock, releaseAnimationLock, findCurrentlyEditingComponent, getTitleArea, getUIManager, setUIManager, addShowListener, removeShowListener, removeAllShowListeners, addOrientationListener, removeOrientationListener, addSizeChangedListener, removeSizeChangedListener, hideNotify, showNotify, sizeChanged, setSafeAreaChanged, isDragRegion, getDragRegionStatus, getGlassPane, setGlassPane, addKeyListener, removeKeyListener, removeGameKeyListener, addGameKeyListener, getSoftButtonCount, getSoftButton, getMenuStyle, setTitleStyle, getDefaultCommand, setDefaultCommand, getClearCommand, setClearCommand, setBackCommand, getBackCommand, setBackCommand, setPopGuard, getPopGuard, checkPopGuard, asContainer, getLayeredPane, getLayeredPane, getLayeredPane, getFormLayeredPane, getLayeredPaneIfExists, getFormLayeredPaneIfExists, setBgImage, stopEditing, isEditing, replace, replaceAndWait, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, isTopLevelShowing, hasMedia, registerAnimated, onRegisterAnimated, deregisterAnimated, getSideGap, paintScrollbars, paintBackground, getTransitionInAnimator, setTransitionInAnimator, getTransitionOutAnimator, setTransitionOutAnimator, addCommandListener, removeCommandListener, dispatchCommand, addPointerPressedListener, removePointerPressedListener, addPointerDraggedListener, removePointerDraggedListener, addPointerReleasedListener, removePointerReleasedListener, addLongPressListener, removeLongPressListener, isSmoothScrolling, setSmoothScrolling, getScrollAnimationSpeed, setScrollAnimationSpeed, onShowCompleted, getComponentForm, getTopLevelContainer, getFocused, setFocused, longKeyPress, longPointerPress, shouldSendPointerReleaseToOtherForm, getNextComponent, getPreviousComponent, getTabIterator, keyPressed, isMinimizeOnBack, setMinimizeOnBack, keyRepeated, resumeDragAfterScrolling, addComponentAwaitingRelease, removeComponentAwaitingRelease, clearComponentsAwaitingRelease, pointerDragged, pointerDragged, pointerHoverReleased, pointerHoverPressed, pointerHover, isSingleFocusMode, isScrollVisible, setScrollVisible, getComponentIndex, getCommandCount, getCommand, addCommand, findNextFocusVertical, findNextFocusHorizontal, isCyclicFocus, setCyclicFocus, scrollComponentToVisible, setMenuCellRenderer, setRTL, paint, isScrollable, isScrollableX, setScrollableX, isScrollableY, setScrollableY, setVisible, getTintColor, setTintColor, setMenuTransitions, paramString, getMenuBar, setMenuBar, setToolBar, getToolbar, setToolbar, isFocusScrolling, setFocusScrolling, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, getEditOnShow, setEditOnShow

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, repaint, repaint, registerForAnimation, deregisterFromAnimation, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, stopScrollMomentum, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removeDragFinishedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setIsScrollVisible, startEditingAsync, isEditable, laidOut, deinitialize, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, isTactileTouch, isTactileTouch, setTactileTouch, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Field details

TYPE_NONE

public static final int TYPE_NONE = 0
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

TYPE_ALARM

public static final int TYPE_ALARM = 1
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

TYPE_CONFIRMATION

public static final int TYPE_CONFIRMATION = 2
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

TYPE_ERROR

public static final int TYPE_ERROR = 3
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

TYPE_INFO

public static final int TYPE_INFO = 4
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

TYPE_WARNING

public static final int TYPE_WARNING = 5
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set

Constructor details

Dialog

public Dialog(String title)
Constructs a Dialog with a title

Parameters

title String
the title of the dialog

Dialog

public Dialog(String title, Layout lm)
Constructs a Dialog with a title

Parameters

title String
the title of the dialog
lm Layout
the layout for the dialog

Dialog

public Dialog()
Constructs a Dialog

Dialog

public Dialog(Layout lm)
Constructs a Dialog with a layout

Parameters

lm Layout
the layout manager

Method details

isDefaultDisposeWhenPointerOutOfBounds

public static boolean isDefaultDisposeWhenPointerOutOfBounds()
The default pointer out of bounds dispose behavior, notice that this only applies to dialogs and not popup dialogs where this is always true by default

Returns

the defaultDisposeWhenPointerOutOfBounds

setDefaultDisposeWhenPointerOutOfBounds

public static void setDefaultDisposeWhenPointerOutOfBounds(boolean aDefaultDisposeWhenPointerOutOfBounds)
The default pointer out of bounds dispose behavior, notice that this only applies to dialogs and not popup dialogs where this is always true by default

Parameters

aDefaultDisposeWhenPointerOutOfBounds boolean
the defaultDisposeWhenPointerOutOfBounds to set

show

public static boolean show(String title, String text, int type, Image icon, String okText, String cancelText)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
okText String
the text to appear in the command dismissing the dialog
cancelText String
optionally null for a text to appear in the cancel command for canceling the dialog

Returns

true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static boolean show(String title, String text, int type, Image icon, String okText, String cancelText, long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
okText String
the text to appear in the command dismissing the dialog
cancelText String
optionally null for a text to appear in the cancel command for canceling the dialog
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used

Returns

true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used

Returns

the command pressed by the user

show

public static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
defaultCommand Command
command to be assigned as the default command or null
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used

Returns

the command pressed by the user

show

public static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout, Transition transition)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used
transition Transition
the transition installed when the dialog enters/leaves

Returns

the command pressed by the user

show

public static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
defaultCommand Command
command to be assigned as the default command or null
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used
transition Transition
the transition installed when the dialog enters/leaves

Returns

the command pressed by the user

show

public static boolean show(String title, String text, String okText, String cancelText)
Shows a modal prompt dialog with the given title and text.

Parameters

title String
The title for the dialog optionally null;
text String
the text displayed in the dialog
okText String
the text to appear in the command dismissing the dialog
cancelText String
optionally null for a text to appear in the cancel command for canceling the dialog

Returns

true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static Command show(String title, Component body, Command... cmds)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body Component
component placed in the center of the dialog
cmds Command...
commands that are added to the form any click on any command will dispose the form

Returns

the command pressed by the user

show

public static Command show(String title, String body, Command... cmds)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body String
text placed in the center of the dialog
cmds Command...
commands that are added to the form any click on any command will dispose the form

Returns

the command pressed by the user

show

public static Command show(String title, Component body, Command[] cmds, int type, Image icon)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body Component
component placed in the center of the dialog
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null

Returns

the command pressed by the user

show

public static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body Component
component placed in the center of the dialog
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used

Returns

the command pressed by the user

show

public static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout, Transition transition)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body Component
component placed in the center of the dialog
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 infinite time is used
transition Transition
the transition installed when the dialog enters/leaves

Returns

the command pressed by the user

show

public static Command show(String title, Component body, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)
Shows a modal dialog with the given component as its “body” placed in the center.

Parameters

title String
title for the dialog
body Component
component placed in the center of the dialog
defaultCommand Command
command to be assigned as the default command or null
cmds Command[]
commands that are added to the form any click on any command will dispose the form
type int
the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon Image
the icon for the dialog, can be null
timeout long
a timeout after which null would be returned if timeout is 0 inifinite time is used
transition Transition
the transition installed when the dialog enters/leaves

Returns

the command pressed by the user

getDefaultDialogPosition

public static String getDefaultDialogPosition()
Default screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for futher details.

Returns

position for dialogs on the sceen using BorderLayout orientation tags

setDefaultDialogPosition

public static void setDefaultDialogPosition(String p)
Default screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for futher details.

Parameters

p String
for dialogs on the sceen using BorderLayout orientation tags

getDefaultDialogType

public static int getDefaultDialogType()
The default type for dialogs

Returns

the default type for the dialog

setDefaultDialogType

public static void setDefaultDialogType(int d)
The default type for dialogs

Parameters

d int
the default type for the dialog

isAutoAdjustDialogSize

public static boolean isAutoAdjustDialogSize()
Indicates whether Codename One should try to automatically adjust a showing dialog size when a screen size change event occurs

Returns

true to indicate that Codename One should make a “best effort” to resize the dialog

setAutoAdjustDialogSize

public static void setAutoAdjustDialogSize(boolean a)
Indicates whether Codename One should try to automatically adjust a showing dialog size when a screen size change event occurs

Parameters

a boolean
true to indicate that Codename One should make a “best effort” to resize the dialog

isDisableStaticDialogScrolling

public static boolean isDisableStaticDialogScrolling()
Allows a developer to indicate his interest that the dialog should no longer scroll on its own but rather rely on the scrolling properties of internal scrollable containers. This flag only affects the static show methods within this class.

Returns

true if scrolling should be activated, false otherwise

setDisableStaticDialogScrolling

public static void setDisableStaticDialogScrolling(boolean d)
Allows a developer to indicate his interest that the dialog should no longer scroll on its own but rather rely on the scrolling properties of internal scrollable containers. This flag only affects the static show methods within this class.

Parameters

d boolean
indicates whether scrolling should be active or not

isCommandsAsButtons

public static boolean isCommandsAsButtons()
Places commands as buttons at the bottom of the standard static dialogs rather than as softbuttons. This is especially appropriate for devices such as touch devices and devices without the common softbuttons (e.g. blackberries). The default value is false

Returns

true if commands are placed as buttons and not as softbutton keys

setCommandsAsButtons

public static void setCommandsAsButtons(boolean c)
Places commands as buttons at the bottom of the standard static dialogs rather than as softbuttons. This is especially appropriate for devices such as touch devices and devices without the common softbuttons (e.g. blackberries). The default value is false

Parameters

c boolean
true to place commands as buttons and not as softbutton keys

getDefaultBlurBackgroundRadius

public static float getDefaultBlurBackgroundRadius()
Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur. -1 is a special case value that indicates that no blurring should take effect and the default tint mode only should be used

Returns

the defaultBlurBackgroundRadius

setDefaultBlurBackgroundRadius

public static void setDefaultBlurBackgroundRadius(float aDefaultBlurBackgroundRadius)
Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur. -1 is a special case value that indicates that no blurring should take effect and the default tint mode only should be used. Notice that this value can be set using the theme constant: dialogBlurRadiusInt

Parameters

aDefaultBlurBackgroundRadius float
the defaultBlurBackgroundRadius to set

isDefaultTitleCentered

public static boolean isDefaultTitleCentered()
Indicates whether newly-created dialogs place their title in the absolute center, with the body below it. This default can be configured with the dialogTitleCenterBool theme constant.

Returns

true when newly-created dialogs use the centered title layout

setDefaultTitleCentered

public static void setDefaultTitleCentered(boolean defaultTitleCentered)
Sets whether newly-created Dialog and InteractionDialog instances place their title in the absolute center, with the body below it.

Parameters

defaultTitleCentered boolean
true to use the centered title layout by default

isDefaultNativeWindowMode

public static boolean isDefaultNativeWindowMode()

Whether newly created dialogs are backed by a real operating system window on desktop platforms.

This default can be configured globally with the theme constant defaultNativeWindowModeBool.

Returns

true when new dialogs open in their own window

setDefaultNativeWindowMode

public static void setDefaultNativeWindowMode(boolean nativeWindowMode)

Sets whether newly created dialogs are backed by a real operating system window on desktop platforms.

This overrides the theme constant defaultNativeWindowModeBool for the rest of the application’s life.

Parameters

nativeWindowMode boolean
true to open new dialogs in their own window

isNativeWindowMode

public boolean isNativeWindowMode()

Whether this dialog is backed by a real operating system window.

Resolved when the dialog is shown, in this order: what #setNativeWindowMode(boolean) was told, else #isDefaultNativeWindowMode(), else the theme constant behind it. A platform with no windowing system ignores all three and shows the dialog the ordinary way – the setting is a preference about how to render, not a contract, so shared code does not have to guard it.

Returns

true when this dialog asks for its own window

setNativeWindowMode

public void setNativeWindowMode(boolean nativeWindowMode)

Sets whether this dialog is backed by a real operating system window.

Takes effect the next time the dialog is shown. A dialog already on screen is never moved between the two: there is no safe point to reparent a live, focused, possibly editing hierarchy while a caller is parked waiting for it.

Parameters

nativeWindowMode boolean
true to open this dialog in its own window

getNativeWindow

public Window getNativeWindow()
The window backing this dialog while it is showing.

Returns

the window, or null when the dialog is not in one

initNativeWindow

protected void initNativeWindow(Window w)
Called once the window backing this dialog has been configured and before it is shown, so an application can adjust it – make it resizable, give it an icon, take its decoration away.

Parameters

w Window
the window about to be shown

isDefaultInteractionDialogMode

public static boolean isDefaultInteractionDialogMode()

Indicates whether newly-created dialogs should use InteractionDialog under the hood.

This default can be configured globally using the theme constant defaultInteractionDialogModeBool.

setDefaultInteractionDialogMode

public static void setDefaultInteractionDialogMode(boolean defaultInteractionDialogMode)

Indicates whether newly-created dialogs should use InteractionDialog under the hood.

This value overrides the theme constant defaultInteractionDialogModeBool for the remainder of the app lifecycle.

isInteractionDialogMode

public boolean isInteractionDialogMode()
Indicates whether this dialog should use InteractionDialog under the hood.

setInteractionDialogMode

public void setInteractionDialogMode(boolean interactionDialogMode)
Indicates whether this dialog should use InteractionDialog under the hood.

setPreviousForm

public void setPreviousForm(Form previousForm)
When the dialog is disposed this form will show. Notice that this can only be set after show was invoked!

Parameters

previousForm Form
the previous form

initGlobalToolbar

protected final void initGlobalToolbar()

Overriden to disable the toolbar in dialogs

Allows subclasses to disable the global toolbar for a specific form by overriding this method

getContentPane

public Container getContentPane()
This method returns the Content pane instance

Returns

a content pane instance

getLayout

public Layout getLayout()
Returns the layout manager of the form’s content pane.

Returns

the container layout manager

setLayout

public final void setLayout(Layout layout)
Sets the layout manager responsible for arranging this container

Parameters

layout Layout
the specified layout manager

getTitle

public String getTitle()
Returns the Form title text

Returns

returns the form title

setTitle

public final void setTitle(String title)
Sets the Form title to the given text

Parameters

title String
the form title

addComponent

public final void addComponent(Component cmp)
Adds Component to the Form’s Content Pane

Parameters

cmp Component
the added param

addComponent

public void addComponent(Object constraints, Component cmp)
Adds a Component to the Container

Parameters

constraints Object
this method is useful when the Layout requires a constraint such as the BorderLayout. In this case you need to specify an additional data when you add a Component, such as “CENTER”, “NORTH”…
cmp Component
component to add

addComponent

public void addComponent(int index, Object constraints, Component cmp)
Adds a Component to the Container

Parameters

index int
location to insert the Component
constraints Object
this method is useful when the Layout requires a constraint such as the BorderLayout. In this case you need to specify an additional data when you add a Component, such as “CENTER”, “NORTH”…
cmp Component
component to add

addComponent

public void addComponent(int index, Component cmp)
Adds Component to the Form’s Content Pane

Parameters

index int
location to insert the Component
cmp Component
the added param

Throws

ArrayIndexOutOfBoundsException
if index is out of bounds
IllegalArgumentException
if Component is already contained or the cmp is a Form Component

removeAll

public void removeAll()
Removes all Components from the Content Pane

removeComponent

public void removeComponent(Component cmp)
Removes a component from the Form’s Content Pane

Parameters

cmp Component
the component to be removed

refreshTheme

public void refreshTheme(boolean merge)

Refreshing the theme reinstalls the menu bar, and installing it moves the form’s title component into the title area. A dialog’s title component is its own title label, and a dialog keeps the form title area hidden – so without putting the label back where it belongs, refreshing the theme loses the dialog’s title altogether, along with the space it occupied in the centered-title layout.

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!

Parameters

merge boolean
indicates if the current styles should be merged with the new styles

getTitleComponent

public Label getTitleComponent()
Allows modifying the title attributes beyond style (e.g. setting icon/alignment etc.)

Returns

the component representing the title for the form

setTitleComponent

public void setTitleComponent(Label title)
Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects.

Parameters

title Label
new title component

isTitleCentered

public boolean isTitleCentered()
Returns whether this dialog places its title in the absolute center with the body below it.

Returns

true when the centered title layout is active

setTitleCentered

public void setTitleCentered(boolean titleCentered)
Places the title in the absolute center with the body below it. Passing false restores the traditional title-at-top layout.

Parameters

titleCentered boolean
true to use the centered title layout

getTitleStyle

public Style getTitleStyle()
Returns the style of the title

Returns

the style of the title

getDialogComponent

public Container getDialogComponent()
Returns the container that actually implements the dialog positioning. This container is normally not accessible via the Codename One API.

Returns

internal dialog container useful for various calculations.

setTitleComponent

public void setTitleComponent(Label title, Transition t)
Allows replacing the title with a different title component, thus allowing developers to create more elaborate title objects. This version of the method allows special effects for title replacement such as transitions for title entering

Parameters

title Label
new title component
t Transition
transition for title replacement

getDialogUIID

public String getDialogUIID()
Returns the uiid of the dialog

Returns

the uiid of the dialog

setDialogUIID

public void setDialogUIID(String uiid)
Simple setter to set the Dialog uiid

Parameters

uiid String
the id for the dialog

getDialogStyle

public Style getDialogStyle()
Simple getter to get the Dialog Style

Returns

the style of the dialog

setDialogStyle

public void setDialogStyle(Style style)
Simple setter to set the Dialog Style

initLaf

protected void initLaf(UIManager uim)
Initialize the default transition for the dialogs overriding the forms transition

Parameters

uim UIManager
the UIManager instance

show

public Command show(int top, int bottom, int left, int right, boolean includeTitle)
Deprecated. use the version that doesn’t accept the include title, the includeTitle feature is no longer supported

This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms “content” to “hang in mid air” this is especially useful for dialogs where you would want the underlying form to “peek” from behind the form.

Parameters

top int
space in pixels between the top of the screen and the form
bottom int
space in pixels between the bottom of the screen and the form
left int
space in pixels between the left of the screen and the form
right int
space in pixels between the right of the screen and the form
includeTitle boolean
whether the title should hang in the top of the screen or be glued onto the content pane

Returns

the last command pressed by the user if such a command exists

show

public Command show(int top, int bottom, int left, int right)

This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms “content” to “hang in mid air” this is especially useful for dialogs where you would want the underlying form to “peek” from behind the form.

See this sample for showing a dialog at the bottom of the screen:

Dialog dlg = new Dialog("At Bottom");
dlg.setLayout(new BorderLayout());
// span label accepts the text and the UIID for the dialog body
dlg.add(new SpanLabel("Dialog Body text", "DialogBody"));
int h = Display.getInstance().getDisplayHeight();
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.show(h /8 * 7, 0, 0, 0);

Parameters

top int
space in pixels between the top of the screen and the form
bottom int
space in pixels between the bottom of the screen and the form
left int
space in pixels between the left of the screen and the form
right int
space in pixels between the right of the screen and the form

Returns

the last command pressed by the user if such a command exists

show

public Command show(int top, int bottom, int left, int right, boolean includeTitle, boolean modal)
Deprecated. use showAtPosition, the includeTitle flag is no longer supported

This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms “content” to “hang in mid air” this is especially useful for dialogs where you would want the underlying form to “peek” from behind the form.

Parameters

top int
space in pixels between the top of the screen and the form
bottom int
space in pixels between the bottom of the screen and the form
left int
space in pixels between the left of the screen and the form
right int
space in pixels between the right of the screen and the form
includeTitle boolean
whether the title should hang in the top of the screen or be glued onto the content pane
modal boolean
indicates the dialog should be modal set to false for modeless dialog which is useful for some use cases

Returns

the last command pressed by the user if such a command exists

showAtPosition

public Command showAtPosition(int top, int bottom, int left, int right, boolean modal)

This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms “content” to “hang in mid air” this is especially useful for dialogs where you would want the underlying form to “peek” from behind the form.

Parameters

top int
space in pixels between the top of the screen and the form
bottom int
space in pixels between the bottom of the screen and the form
left int
space in pixels between the left of the screen and the form
right int
space in pixels between the right of the screen and the form
modal boolean
indicates the dialog should be modal set to false for modeless dialog which is useful for some use cases

Returns

the last command pressed by the user if such a command exists

setTimeout

public void setTimeout(long time)
Indicates the time (in milliseconds) afterwhich the dialog will be disposed implicitly

Parameters

time long
a milliseconds time used to dispose the dialog

setTransitions

public void setTransitions(Transition transition)
Sets in/out transition for dialogs that support transitions.

configureCommands

public void configureCommands(Command[] cmds, boolean commandsAsButtons)
Configures commands for the dialog UI.

autoAdjust

protected void autoAdjust(int w, int h)
Auto adjust size of the dialog. This method is triggered from a sizeChanged event.

Parameters

w int
width of the screen
h int
height of the screen

placeButtonCommands

public void placeButtonCommands(Command[] cmds)
Deprecated. this method shouldn’t be invoked externally, it should have been private
Places the given commands in the dialog command area, this is very useful for touch devices.

Parameters

cmds Command[]
the commands to place

keyReleased

public void keyReleased(int keyCode)
If this Component is focused, the key released event will call this method

Parameters

keyCode int
the key code value to indicate a physical key.

onShow

protected void onShow()
Allows subclasses to bind functionality that occurs when a specific form or dialog appears on the screen

showBack

public void showBack()
Displays the current form on the screen, this version of the method is useful for “back” navigation since it reverses the direction of the transition.

setScrollable

public void setScrollable(boolean scrollable)
The equivalent of calling both setScrollableY and setScrollableX

Parameters

scrollable boolean
whether the component should/could scroll on the X and Y axis

show

public void show()
The default version of show modal shows the dialog occupying the center portion of the screen.

showModeless

public void showModeless()
Shows a modeless dialog which is useful for some simpler use cases such as progress indication etc…

setTopLevelHost

public void setTopLevelHost(TopLevelContainer host)

The top level this dialog appears on when it is shown.

A dialog is not attached to anything at the moment it is shown, so it cannot resolve its own host the way an attached component can. Left unset it uses the focused window, else the current Form – which is the historical behaviour and the right answer for an application with one window. Set it to put the dialog on a particular com.codename1.ui.Window instead.

Parameters

host TopLevelContainer
the top level to show on, or null to work it out

getTopLevelHost

public TopLevelContainer getTopLevelHost()
Returns the top level set with #setTopLevelHost(TopLevelContainer).

Returns

the explicit host, or null when none was set

addCommand

public void addCommand(Command cmd, int offset)

Hands menu style commands to the window so the platform can put them wherever it shows a window’s commands.

Button bar commands are deliberately not published: placeButtonCommands never calls addCommand, so a dialog with an OK and a Cancel button has a command count of zero and no native menu is built for them. They are buttons inside the dialog and they stay that way.

Parameters

cmd Command
the Form command to be added
offset int
position in which the command is added

removeCommand

public void removeCommand(Command cmd)

Removes the command from the menu bar softkeys

Taken off the operating system window too. A command removed while the dialog was showing stayed on the platform menu and could still be picked from it, which then reached the dialog through the command bridge as though it were still there.

Parameters

cmd Command
the Form command to be removed

removeAllCommands

public void removeAllCommands()

Clear menu commands from the menu bar

Cleared from the operating system window too, for the same reason.

showPopupDialog

public Command showPopupDialog(Component c)
A popup dialog is shown with the context of a component and its selection, it is disposed seamlessly if the back button is pressed or if the user touches outside its bounds. It can optionally provide an arrow in the theme to point at the context component. The popup dialog has the PopupDialog style by default.

Parameters

c Component
the context component which is used to position the dialog and can also be pointed at

Returns

the command that might have been triggered by the user within the dialog if commands are placed in the dialog

showPopupDialog

public Command showPopupDialog(Rectangle rect)
A popup dialog is shown with the context of a component and its selection, it is disposed seamlessly if the back button is pressed or if the user touches outside its bounds. It can optionally provide an arrow in the theme to point at the context component. The popup dialog has the PopupDialog style by default.

Parameters

rect Rectangle
the screen rectangle to which the popup should point

Returns

the command that might have been triggered by the user within the dialog if commands are placed in the dialog

showPacked

public Command showPacked(String position, boolean modal)
Convenience method to show a dialog sized to match its content.

Parameters

position String
one of the values from the BorderLayout class e.g. BorderLayout.CENTER, BorderLayout.NORTH etc.
modal boolean
whether the dialog should be modal or modaless

Returns

the command selected if the dialog is modal and disposed via a command

showStretched

public Command showStretched(String position, boolean modal)
Convenience method to show a dialog stretched to one of the sides

Parameters

position String
one of the values from the BorderLayout class except for center e.g. BorderLayout.NORTH, BorderLayout.EAST etc.
modal boolean
whether the dialog should be modal or modaless

Returns

the command selected if the dialog is modal and disposed via a command

showStetched

public Command showStetched(String position, boolean modal)
Deprecated. due to typo use showStretched instead
Convenience method to show a dialog stretched to one of the sides

Parameters

position String
one of the values from the BorderLayout class except for center e.g. BorderLayout.NORTH, BorderLayout.EAST etc.
modal boolean
whether the dialog should be modal or modaless

Returns

the command selected if the dialog is modal and disposed via a command

getDialogPreferredSize

public Dimension getDialogPreferredSize()
Returns the preferred size of the dialog, this allows developers to position a dialog manually in arbitrary positions.

Returns

the preferred size of this dialog

dispose

public void dispose()
Closes the current form and returns to the previous form, releasing the EDT in the process

showDialog

public Command showDialog()
Shows a modal dialog and returns the command pressed within the modal dialog

Returns

last command pressed in the modal dialog

actionCommand

protected void actionCommand(Command cmd)
Invoked to allow subclasses of form to handle a command from one point rather than implementing many command instances

Parameters

cmd Command
the action command

animate

public boolean animate()
Allows the animation to reduce “repaint” calls when it returns false. It is called once for every frame. Frames are defined by the com.codename1.ui.Display class.

Returns

true if a repaint is desired or false if no repaint is necessary

isAutoDispose

public boolean isAutoDispose()
Determines whether the execution of a command on this dialog implicitly disposes the dialog. This defaults to true which is a sensible default for simple dialogs.

Returns

true if this dialog disposes on any command

setAutoDispose

public final void setAutoDispose(boolean autoDispose)
Determines whether the execution of a command on this dialog implicitly disposes the dialog. This defaults to true which is a sensible default for simple dialogs.

Parameters

autoDispose boolean
true if this dialog disposes on any command

getDialogType

public int getDialogType()
The type of the dialog can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM

Returns

can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM

setDialogType

public void setDialogType(int dialogType)
The type of the dialog can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM

Parameters

dialogType int
can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM

isDisposeWhenPointerOutOfBounds

public boolean isDisposeWhenPointerOutOfBounds()
This flag indicates if the dialog should be disposed if a pointer released event occurred out of the dialog content.

Returns

true if the dialog should dispose

setDisposeWhenPointerOutOfBounds

public final void setDisposeWhenPointerOutOfBounds(boolean disposeWhenPointerOutOfBounds)
This flag indicates if the dialog should be disposed if a pointer released event occurred out of the dialog content.

pointerReleased

public void pointerReleased(int x, int y)
If this Component is focused, the pointer released event will call this method

Parameters

x int
the pointer x coordinate
y int
the pointer y coordinate

pointerPressed

public void pointerPressed(int x, int y)
If this Component is focused, the pointer pressed event will call this method

Parameters

x int
the pointer x coordinate
y int
the pointer y coordinate

wasDisposedDueToOutOfBoundsTouch

public boolean wasDisposedDueToOutOfBoundsTouch()
Returns true if a dialog that was disposed did it because of a pointer out of bounds

Returns

true when a dialog was disposed due to pointer out of bounds.

getDialogPosition

public String getDialogPosition()
Screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for futher details.

Returns

the dialogPosition

setDialogPosition

public void setDialogPosition(String dialogPosition)
Screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for futher details.

Parameters

dialogPosition String
the dialogPosition to set

growOrShrink

public void growOrShrink()
Allows a dialog component to grow or shrink to its new preferred size

getPopupDirectionBiasPortrait

public Boolean getPopupDirectionBiasPortrait()
Indicates if we want to enforce directional bias for the popup dialog. If null this field is ignored but if its set to a value it biases the system towards a fixed direction for the popup dialog.

Returns

the popupDirectionBiasPortrait

setPopupDirectionBiasPortrait

public void setPopupDirectionBiasPortrait(Boolean popupDirectionBiasPortrait)
Indicates if we want to enforce directional bias for the popup dialog. If null this field is ignored but if its set to a value it biases the system towards a fixed direction for the popup dialog.

Parameters

popupDirectionBiasPortrait Boolean
the popupDirectionBiasPortrait to set

wasDisposedDueToRotation

public boolean wasDisposedDueToRotation()
Returns true if the dialog was disposed automatically due to device rotation

Returns

the disposedDueToRotation value

getBlurBackgroundRadius

public float getBlurBackgroundRadius()
Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur. -1 is a special case value that indicates that no blurring should take effect and the default tint mode only should be used

Returns

the blurBackgroundRadius

setBlurBackgroundRadius

public void setBlurBackgroundRadius(float blurBackgroundRadius)
Dialog background can be blurred using a Gaussian blur effect, this sets the radius of the Gaussian blur. -1 is a special case value that indicates that no blurring should take effect and the default tint mode only should be used. Notice that this value can be set using the theme constant: dialogBlurRadiusInt

Parameters

blurBackgroundRadius float
the blurBackgroundRadius to set

setUIIDByPopupPosition

public void setUIIDByPopupPosition(boolean b)
Allows to use the UIIDs “PopupContentPaneDownwards”, “PopupContentPaneUpwards”, “PopupContentPaneRight”, “PopupContentPaneLeft” (instead of the default UIID “PopupContentPane”) to style the PopupDialog more accurately based on the position of the dialog popup compared to the context component.

Parameters

b boolean
to enable