Class InteractionDialog

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.components.InteractionDialog
All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class InteractionDialog extends Container

Unlike a regular dialog the interaction dialog only looks like a dialog, it resides in the layered pane and can be used to implement features where interaction with the background form is still required.

Since this code is designed for interaction all "dialogs" created thru here are modless and never block.

InteractionDialog dlg = new InteractionDialog("Hello");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, new Label("Hello Dialog"));
Button close = new Button("Close");
close.addActionListener((ee) -> dlg.dispose());
dlg.addComponent(BorderLayout.SOUTH, close);
Dimension pre = dlg.getContentPane().getPreferredSize();
dlg.show(0, 0, Display.getInstance().getDisplayWidth() - (pre.getWidth() + pre.getWidth() / 6), 0);
  • Constructor Details

    • InteractionDialog

      public InteractionDialog()
      Default constructor with no title
    • InteractionDialog

      public InteractionDialog(Layout l)

      Default constructor with layout

      Parameters
      • l: layout
    • InteractionDialog

      public InteractionDialog(String title)

      Constructor with dialog title

      Parameters
      • title: the title of the dialog
    • InteractionDialog

      public InteractionDialog(String title, Layout l)

      Constructor with dialog title

      Parameters
      • title: the title of the dialog

      • l: the layout for the content pane

  • Method Details

    • initComponent

      protected void initComponent()
      Description copied from class: Component
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • 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 void setDisposeWhenPointerOutOfBounds(boolean disposeWhenPointerOutOfBounds)

      This flag indicates if the dialog should be disposed if a pointer released event occurred out of the dialog content.

      Parameters
      • disposeWhenPointerOutOfBounds
    • getContentPane

      public Container getContentPane()

      Returns the body of the interaction dialog

      Returns

      the container where the elements of the interaction dialog are added.

    • setScrollable

      public void setScrollable(boolean scrollable)

      The equivalent of calling both setScrollableY and setScrollableX

      Parameters
      • scrollable: @param scrollable whether the component should/could scroll on the X and Y axis
      Deprecated

      use setScrollableX and setScrollableY instead. This method is deprecated since it breeds confusion and is often misunderstood.

      Overrides:
      setScrollable in class Container
    • getLayout

      public Layout getLayout()

      Returns the layout manager responsible for arranging this container.

      Returns

      the container layout manager

      Overrides:
      getLayout in class Container
    • setLayout

      public void setLayout(Layout layout)

      Sets the layout manager responsible for arranging this container

      Parameters
      • layout: the specified layout manager
      Overrides:
      setLayout in class Container
    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • addComponent

      public void addComponent(Component cmp)

      Adds a Component to the Container

      Parameters
      • cmp: the component to be added
      Overrides:
      addComponent in class Container
    • addComponent

      public void addComponent(Object constraints, Component cmp)

      Adds a Component to the Container

      Parameters
      • constraints: @param constraints 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 to add

      Overrides:
      addComponent in class Container
    • addComponent

      public void addComponent(int index, Object constraints, Component cmp)

      Adds a Component to the Container

      Parameters
      • index: location to insert the Component

      • constraints: @param constraints 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 to add

      Overrides:
      addComponent in class Container
    • addComponent

      public void addComponent(int index, Component cmp)

      This method adds the Component at a specific index location in the Container Components array.

      Parameters
      • index: location to insert the Component

      • cmp: the Component to add

      Throws
      • ArrayIndexOutOfBoundsException: if index is out of bounds

      • IllegalArgumentException: @throws IllegalArgumentException if Component is already contained or the cmp is a Form Component

      Overrides:
      addComponent in class Container
    • removeAll

      public void removeAll()
      remove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed. Calling form.repaint() will workaround such an issue. Notice that this method doesn't recurse and only removes from the current container.
      Overrides:
      removeAll in class Container
    • removeComponent

      public void removeComponent(Component cmp)

      removes a Component from the Container, notice that removed component might still have a pending repaint in the queue that won't be removed. Calling form.repaint() will workaround such an issue.

      Parameters
      • cmp: the removed component
      Overrides:
      removeComponent in class Container
    • getTitleComponent

      public Label getTitleComponent()
    • deinitialize

      protected void deinitialize()
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
      Overrides:
      deinitialize in class Component
    • resize

      public void resize(int top, int bottom, int left, int right)
    • show

      public void 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.

      Parameters
      • top: space in pixels between the top of the screen and the form

      • bottom: space in pixels between the bottom of the screen and the form

      • left: space in pixels between the left of the screen and the form

      • right: space in pixels between the right of the screen and the form

    • dispose

      public void dispose()
      Removes the interaction dialog from view
    • disposeToTheLeft

      public void disposeToTheLeft()
      Removes the interaction dialog from view with an animation to the left
    • disposeToTheBottom

      public void disposeToTheBottom()
      Removes the interaction dialog from view with an animation to the bottom
    • disposeToTheBottom

      public void disposeToTheBottom(Runnable onFinish)

      Removes the interaction dialog from view with an animation to the bottom

      Parameters
      • onFinish: Callback called when dispose animation is complete.
    • disposeToTheTop

      public void disposeToTheTop()
      Removes the interaction dialog from view with an animation to the top
    • disposeToTheRight

      public void disposeToTheRight()
      Removes the interaction dialog from view with an animation to the right
    • isShowing

      public boolean isShowing()

      Will return true if the dialog is currently showing

      Returns

      true if showing

    • isAnimateShow

      public boolean isAnimateShow()

      Indicates whether show/dispose should be animated or not

      Returns

      the animateShow

    • setAnimateShow

      public void setAnimateShow(boolean animateShow)

      Indicates whether show/dispose should be animated or not

      Parameters
      • animateShow: the animateShow to set
    • showPopupDialog

      public void showPopupDialog(Component c)

      A popup dialog is shown with the context of a component and its selection. You should use #setDisposeWhenPointerOutOfBounds(boolean) to make it dispose when the user clicks outside the bounds of the popup. 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: the context component which is used to position the dialog and can also be pointed at
    • showPopupDialog

      public void showPopupDialog(Component c, boolean bias)

      A popup dialog is shown with the context of a component and its selection. You should use #setDisposeWhenPointerOutOfBounds(boolean) to make it dispose when the user clicks outside the bounds of the popup. 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: the context component which is used to position the dialog and can also be pointed at

      • bias: @param bias biases the dialog to appear above/below or to the sides. This is ignored if there isn't enough space

    • showPopupDialog

      public void showPopupDialog(Rectangle rect)

      A popup dialog is shown with the context of a component and its selection. You should use #setDisposeWhenPointerOutOfBounds(boolean) to make it dispose when the user clicks outside the bounds of the popup. 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: the screen rectangle to which the popup should point
    • showPopupDialog

      public void showPopupDialog(Rectangle rect, boolean bias)

      A popup dialog is shown with the context of a component and its selection. You should use #setDisposeWhenPointerOutOfBounds(boolean) to make it dispose when the user clicks outside the bounds of the popup. 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: the screen rectangle to which the popup should point

      • bias: @param bias biases the dialog to appear above/below or to the sides. This is ignored if there isn't enough space

    • 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: the id for the dialog
    • getDialogStyle

      public Style getDialogStyle()

      Simple getter to get the Dialog Style

      Returns

      the style of the dialog

    • isRepositionAnimation

      public boolean isRepositionAnimation()

      Repositions the component so the animation will "grow/shrink" when showing/disposing

      Returns

      the repositionAnimation

    • setRepositionAnimation

      public void setRepositionAnimation(boolean repositionAnimation)

      Repositions the component so the animation will "grow/shrink" when showing/disposing

      Parameters
      • repositionAnimation: the repositionAnimation to set
    • isFormMode

      public boolean isFormMode()

      Whether the interaction dialog uses the form layered pane of the regular layered pane

      Returns

      the formMode

    • setFormMode

      public void setFormMode(boolean formMode)

      Whether the interaction dialog uses the form layered pane of the regular layered pane

      Parameters
      • formMode: the formMode to set