Class ModalWindow

All Implemented Interfaces:
Animatable<ModalWindow>, HandleHotKey<ModalWindow>, HandleMouseEvents<ModalWindow>, Scrollable<ModalWindow>

Modal window component

A modal window can be placed on the interface with the use of this component. In a modal window, the user can only do the operation, that is in the window. The modal window can be given parameterized, whether the window will be closed when the ESC button is pressed.

In the window there are 3 areas: The header, the content and the footer. These can all have components added to them, and they will be displayed in their respective area.

Supported events:

AnimationStart AnimationEnd, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable HotKey

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • ModalWindow

      public ModalWindow()
      Creates an empty modal window
    • ModalWindow

      public ModalWindow(String id)
      Creates an empty modal window with specified ID
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
  • Method Details

    • init

      public void init() throws JavaScriptLoadError
      Description copied from class: Component
      The component initialization method.

      Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.

      Overrides:
      init in class Component<ModalWindow>
      Throws:
      JavaScriptLoadError - If there was a JavaScript error during the initialization.
    • setHeaderIcon

      public ModalWindow setHeaderIcon(Icon icon)
      Sets the modal window header icon
      Parameters:
      icon - The icon that will be used. For the usable icons, see the Icon enum.
      Returns:
      The modal window
    • setTitle

      public ModalWindow setTitle(String text)
      Sets the modal window header text
      Parameters:
      text - The modal window header text
      Returns:
      The modal window
    • addTitleComponent

      public ModalWindow addTitleComponent(Component<?> component)
      Adds a component to the title of the modal window. If you want to use multiple components in the title bar, you have to place them into a container (e.g. a Div or Container component) and add the container to the modal window’s title.
      Parameters:
      component - Component in the modal window’s title
      Returns:
      The modal window
    • setShowHeader

      public ModalWindow setShowHeader(boolean showHeader)
      Sets the header to be displayed. Defaults to true.
      Parameters:
      showHeader - If true the header is shown, otherwise the header will not be shown.
      Returns:
      The modal window
    • setShowFooter

      public ModalWindow setShowFooter(boolean showFooter)
      Sets the footer to be displayed. Defaults to true.
      Parameters:
      showFooter - If true, the footer will be shown, otherwise it will not.
      Returns:
      The modal window
    • getHeader

      public ModalWindow.ModalHeader getHeader()
      Gets the modal window header component
      Returns:
      The modal window header component
    • getFooter

      public ModalWindow.ModalFooter getFooter()
      Gets the modal window footer component
      Returns:
      The modal window footer component
    • show

      public ModalWindow show()
      Shows the modal window on the interface. By default, the modal window is not displayed, it is drawn, but hidden. If this method is called, the window will be shown, and the user will only be able to use the application, if the window is closed. While the window is shown, only it's components can be used,
      Returns:
      The modal window
    • hide

      public ModalWindow hide()
      Hides the modal window from the interface.
      Returns:
      The modal window
    • setWidth

      public ModalWindow setWidth(String width)
      Sets the width of the modal window.
      Parameters:
      width - The width, specified in pixel or percent
      Returns:
      The modal window
    • setHeight

      public ModalWindow setHeight(String height)
      Sets the height of the modal window.
      Parameters:
      height - The height, specified in pixel or precent
      Returns:
      The modal window
    • addComponent

      public ModalWindow addComponent(Component<?> component)
      Adds the specified component to the modal window contents.
      Overrides:
      addComponent in class Component<ModalWindow>
      Parameters:
      component - The component to be added
      Returns:
      The component
    • removeComponent

      public ModalWindow removeComponent(Component<?> component)
      Removes the specified component from the modal window contents.
      Overrides:
      removeComponent in class Component<ModalWindow>
      Parameters:
      component - The component instance
      Returns:
      The component
    • setCloseWithESC

      public ModalWindow setCloseWithESC(boolean closeWithESC)
      If set, the modal window can be closed by pressing the ESC button. By default, this is enabled.
      Parameters:
      closeWithESC - If true, the window can be closed by the ESC button, otherwise, not.
      Returns:
      The modal window
    • isCloseWithESC

      public boolean isCloseWithESC()
      Determines if the window can be closed by pressing the ESC button.
      Returns:
      If true, the window can be closed by the ESC button, otherwise false
    • setModal

      public ModalWindow setModal(boolean modal)
      Sets the window to be modal. If the window is modal, nothing will happen if the user clicks outside the window. Otherwise, the window will be closed if the user clicks outside it. By default, the window is set to be modal (true).
      Parameters:
      modal - If true, the window will be modal, meaning it won't close if the user clicks outside it. If false, the window will be closed if the user clicks outside it.
      Returns:
      The modal window
    • isModal

      public boolean isModal()
      Determines if the window is modal.
      Returns:
      If true, the window is modal, otherwise false.
    • setResizeable

      public ModalWindow setResizeable(boolean resizeable, int minWidth, int minHeight)
      Sets if a window can be resized. By default, a window cannot be resized.
      Parameters:
      resizeable - If true is specified, the user is allowed to resize the window
      minWidth - The user cannot set the window width to a smaller value than the one specified in this parameter Width must be specified in pixels.
      minHeight - The user cannot set the window width to a greater value than the one specified in this parameter Height must be specified in pixels.
      Returns:
      Modal window
    • isResizeable

      public boolean isResizeable()
      Sets if a window can be resized.
      Returns:
      If true is returned, the user is allowed to resize the window, otherwise not
    • addScrollHandler

      public ModalWindow addScrollHandler(ScrollEventHandler handler)
      Description copied from interface: Scrollable
      Adds a Scroll event handler to the component. It will run when the user is scrolling the component content.
      Specified by:
      addScrollHandler in interface Scrollable<ModalWindow>
      Parameters:
      handler - The ScrollEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseDownHandler

      public ModalWindow addMouseDownHandler(MouseDownEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse button down event handler to the component. The handler will run when the user presses a mouse button while having the mouse in the component
      Specified by:
      addMouseDownHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseDownEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseEnterHandler

      public ModalWindow addMouseEnterHandler(MouseEnterEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse enter event handler to the component. The handler will run when the mouse cursor enters the component, i.e. when the user hovers with the mouse over the component.
      Specified by:
      addMouseEnterHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseEnterEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseLeaveHandler

      public ModalWindow addMouseLeaveHandler(MouseLeaveEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse leave event handler to the component. The handler will run when the mouse cursor leaves the component.
      Specified by:
      addMouseLeaveHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseLeaveEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseMoveHandler

      public ModalWindow addMouseMoveHandler(MouseMoveEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse move event handler to the component. The handler will run when the mouse cursor moves inside the component area.
      Specified by:
      addMouseMoveHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseMoveEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseOverHandler

      public ModalWindow addMouseOverHandler(MouseOverEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse over event handler to the component. The handler will run when the mouse cursor moves over a component
      Specified by:
      addMouseOverHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseOverEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseOutHandler

      public ModalWindow addMouseOutHandler(MouseOutEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse out event handler to the component. The handler will run when the mouse cursor moves out of a component
      Specified by:
      addMouseOutHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseOutEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseUpHandler

      public ModalWindow addMouseUpHandler(MouseUpEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse up event handler to the component. The handler will run when the mouse button is released, while the cursor is in a component.
      Specified by:
      addMouseUpHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseUpEventHandler implementation
      Returns:
      The component
      See Also:
    • addMouseWheelHandler

      public ModalWindow addMouseWheelHandler(MouseWheelEventHandler handler)
      Description copied from interface: HandleMouseEvents
      Adds a mouse wheel event handler to the component. The handler will run when the mouse wheel is used (scrolling), while the cursor is in a component
      Specified by:
      addMouseWheelHandler in interface HandleMouseEvents<ModalWindow>
      Parameters:
      handler - The MouseWheelEventHandler implementation
      Returns:
      The component
      See Also:
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<ModalWindow>
      Returns:
      If the componentwas drawn, true, otherwise false