Interface IWindow<I extends IAnyGroup>

All Superinterfaces:
IAnyGroup<IWindow<I>>, IChildable<IWindow<I>,I>, IComponent<IWindow<I>>, IComposite<IWindow<I>,IAnyGroup>, IHtmlBasedComponent<IWindow<I>>, IXulElement<IWindow<I>>

public interface IWindow<I extends IAnyGroup> extends IXulElement<IWindow<I>>, IChildable<IWindow<I>,I>, IAnyGroup<IWindow<I>>, IComposite<IWindow<I>,IAnyGroup>
Immutable Window component

Support @Action

Name Action Type
onMove ActionData: MoveData
Denotes the position of the window is moved by a user.
onOpen ActionData: OpenData
Denotes user has opened or closed a component.
onMaximize ActionData: MaximizeData
Denotes user has maximize a component.
onMinimize ActionData: MinimizeData
Denotes user has minimize a component.
onClose ActionData: OpenData
Denotes the close button is pressed by a user, and the component shall detach itself.
onSize ActionData: SizeData
Denotes the panel's size is updated by a user.
onZIndex ActionData: ZIndexData
Denotes the panel's zindex is updated by a user.

Support Application Library Properties

  • To set to use Browser's scrollbar or not, you have to specify withNativeScrollbar(boolean).

    Or configure it from zk.xml by setting library properties. For example,

      <library-property/>
         <name>org.zkoss.zul.nativebar</name/>
         <value>false</value/>
     </library-property/>
     
     

Modes

Embedded

An embedded window is placed inline with other components. In this mode, you cannot change its position, since the position is decided by the browser. It is the default mode since it is the most common appearance.

Overlapped

An overlapped window is overlapped with other components, such that users could drag it around and developer could set its position by IHtmlBasedComponent.withLeft(String) and IHtmlBasedComponent.withTop(String).

Popup

A popup window is similar to overlapped windows, except it is automatically closed when user clicks on any component other than the popup window itself or any of its descendants. Of course, you could dismiss it manually by making it invisible or detaching it.

As its name suggested, it is designed to implement the popup windows. A typical application is to display information that won't obscure the current operation and are easy to close. A popup window is usually position around the focal point (such as a button). It can be done by use of withPosition(String) with "parent".

Modal and Highlighted

By default, a modal window is the same as a highlighted window in stateless.

A modal window provides the so-called modal effect that limits a user from accessing components other than the modal window. Users cannot access anything outside of the modal window, including clicking or tabbing.

Position

In addition to the left and top properties, you can control the position of an overlapped/popup/modal/highlighted window by the use of the position attribute. For example, the following code snippet positions the window to the right-bottom corner.

 
 IWindow.ofMode(Mode.OVERLAPPED).withWidth("300px").withPosition("right,bottom");
 

The value of the position attribute can be a combination of the following constants by separating them with comma (,).

Constant
Description
center
Position the window at the center. If left or right is also specified, it means the vertical center. If top or bottom is also specified, it means the horizontal center. If none of left, right, top and bottom is specified, it means the center in both directions.

Both the left and top property are ignored.

left
Position the window at the left edge.

The left property is ignored.

right
Position the window at the right edge.

The left property is ignored.

top
Position the window at the top.

The top property is ignored.

bottom
Position the window at the bottom.

The top property is ignored.

Author:
katherine
See Also:
  • Window
  • Field Details

    • DEFAULT

      static final IWindow<IAnyGroup> DEFAULT
      Constant for default attributes of this immutable component.
  • Method Details

    • getWidgetClass

      default String getWidgetClass()
      Returns the client widget class.

      Default: "zul.wnd.Window"

      Specified by:
      getWidgetClass in interface IComponent<I extends IAnyGroup>
    • getCaption

      @Nullable ICaption getCaption()
      Returns the caption of this window.
    • withCaption

      IWindow<I> withCaption(@Nullable ICaption caption)
      Returns a copy of this immutable component with the specified caption.

      Sets the caption child of this component.

      Parameters:
      caption - The caption child of the component.

      Default: null.

      Returns:
      A modified copy of the this object
    • getTitle

      default String getTitle()
      Returns the title. Besides this attribute, you could use ICaption to define a more sophisticated caption (a.k.a., title).

      If a window has a caption whose label (ILabelElement.getLabel()) is not empty, then this attribute is ignored.

      Default: "" (empty).

    • withTitle

      IWindow<I> withTitle(String title)
      Returns a copy of this immutable component with the specified title.

      Sets the title of this component.

      Parameters:
      title - The title of this component.

      Default: "" (empty).

      Returns:
      A modified copy of the this object
    • getMode

      default String getMode()
      Returns the current mode.

      Default: "embedded"

    • withMode

      IWindow<I> withMode(String mode)
      Returns a copy of this immutable component with the specified mode.

      Sets the mode to "overlapped", "popup", "modal", "embedded" or "highlighted".

      Parameters:
      mode - The mode of this component.

      Default: "embedded".

      Returns:
      A modified copy of the this object
    • withMode

      default IWindow<I> withMode(IWindow.Mode mode)
      Returns a copy of this immutable component with the specified mode.

      Sets the mode to IWindow.Mode.

      Parameters:
      mode - The mode of this component.

      Default: "embedded".

      Returns:
      A modified copy of the this object
    • getPosition

      @Nullable String getPosition()
      Returns how to position the window at the client screen. It is meaningless if the embedded mode is used.

      Default: null which depends on getMode(): If overlapped or popup, IHtmlBasedComponent.withLeft(java.lang.String) and IHtmlBasedComponent.withTop(java.lang.String) are assumed. If modal or highlighted, it is centered.

    • withPosition

      IWindow<I> withPosition(@Nullable String position)
      Returns a copy of this immutable component with the specified position.

      Sets how to position the window at the client screen. It is meaningless if the embedded mode is used.

      Parameters:
      position - How to position. It can be null (the default), or a combination of the following values (by separating with comma).
      center
      Position the window at the center. IHtmlBasedComponent.withTop(java.lang.String) and IHtmlBasedComponent.withLeft(java.lang.String) are both ignored.
      nocenter
      Not to position the window at the center. A modal window, by default, will be position at the center. By specifying this value could prevent it and the real position depends on IHtmlBasedComponent.withTop(java.lang.String) and IHtmlBasedComponent.withLeft(java.lang.String)
      left
      Position the window at the left edge. IHtmlBasedComponent.withLeft(java.lang.String) is ignored.
      right
      Position the window at the right edge. IHtmlBasedComponent.withLeft(java.lang.String) is ignored.
      top
      Position the window at the top edge. IHtmlBasedComponent.withTop(java.lang.String) is ignored.
      bottom
      Position the window at the bottom edge. IHtmlBasedComponent.withTop(java.lang.String) is ignored.
      parent
      Position the window relative to its parent. That is, the left and top (IHtmlBasedComponent.getTop() and IHtmlBasedComponent.getLeft()) is an offset to his parent's let-top corner.

      For example, "left,center" means to position it at the center of the left edge.

      Returns:
      A modified copy of the this object
    • getContentStyle

      @Nullable String getContentStyle()
      Returns the CSS style for the content block of the window.

      Default: null

    • withContentStyle

      IWindow<I> withContentStyle(@Nullable String contentStyle)
      Returns a copy of this immutable component with the specified contentStyle.

      Sets the CSS style for the content block of the window.

      Parameters:
      contentStyle - The CSS style for the content block of the window.

      Default: null.

      Returns:
      A modified copy of the this object
    • getContentSclass

      @Nullable String getContentSclass()
      Returns the style class used for the content block.

      Default: null

    • withContentSclass

      IWindow<I> withContentSclass(@Nullable String contentSclass)
      Returns a copy of this immutable component with the specified contentSclass.

      Sets the style class used for the content block.

      Parameters:
      contentSclass - The style class used for the content block.

      Default: null.

      Returns:
      A modified copy of the this object
    • isClosable

      default boolean isClosable()
      Returns whether to show a close button on the title bar.
    • withClosable

      IWindow<I> withClosable(boolean closable)
      Returns a copy of this immutable component with the specified closable.

      Sets whether to show a close button on the title bar. If closable, a button is displayed and the onClose action is sent if a user clicks the button.

      Parameters:
      closable - Whether to show a close button on the title bar.

      Default: false.

      Note: the close button won't be displayed if no title or caption at all.

      Returns:
      A modified copy of the this object
    • isMaximizable

      default boolean isMaximizable()
      Returns whether to display the maximizing button and allow the user to maximize the window.

      Default: false.

    • withMaximizable

      IWindow<I> withMaximizable(boolean maximizable)
      Returns a copy of this immutable component with the specified maximizable.

      Sets whether to display the maximizing button and allow the user to maximize the window.

      Parameters:
      maximizable - Whether to display the maximizing button

      Default: false.

      Returns:
      A modified copy of the this object
    • isMinimizable

      default boolean isMinimizable()
      Returns whether to display the minimizing button and allow the user to minimize the window.

      Default: false.

    • withMinimizable

      IWindow<I> withMinimizable(boolean minimizable)
      Returns a copy of this immutable component with the specified minimizable.

      Sets whether to display the minimizing button and allow the user to minimize the window.

      Parameters:
      minimizable - Whether to show a minimizing button.

      Default: false.

      Returns:
      A modified copy of the this object
    • isMaximized

      default boolean isMaximized()
      Returns whether the window is maximized.

      Default: false

    • withMaximized

      IWindow<I> withMaximized(boolean maximized)
      Returns a copy of this immutable component with the specified maximized.

      Sets whether the window is maximized.

      Parameters:
      maximized - Whether the window is maximized.

      Default: false.

      Returns:
      A modified copy of the this object
    • isMinimized

      default boolean isMinimized()
      Returns whether the window is minimized.

      Default: false.

    • withMinimized

      IWindow<I> withMinimized(boolean minimized)
      Returns a copy of this immutable component with the specified minimized.

      Sets whether the window is minimized.

      Parameters:
      minimized - Whether the window is minimized.

      Default: false.

      Returns:
      A modified copy of the this object
    • isSizable

      default boolean isSizable()
      Returns whether the window is sizable.

      Default: false

    • withSizable

      IWindow<I> withSizable(boolean sizable)
      Returns a copy of this immutable component with the specified sizable.

      Sets whether the window is sizable.

      Parameters:
      sizable - Whether the window is sizable.

      Default: false.

      Returns:
      A modified copy of the this object
    • getMinheight

      default int getMinheight()
      Returns the minimum height.

      Default: 100.

    • withMinheight

      IWindow<I> withMinheight(int minheight)
      Returns a copy of this immutable component with the specified minheight.

      Sets the minimum height in pixels allowed for this panel. If negative, 100 is assumed.

      Parameters:
      minheight - Whether the panel is sizable.

      Default: 100.

      Returns:
      A modified copy of the this object
    • getMinwidth

      default int getMinwidth()
      Returns the minimum width.

      Default: 200.

    • withMinwidth

      IWindow<I> withMinwidth(int minwidth)
      Returns a copy of this immutable component with the specified minwidth.

      Sets the minimum width in pixels allowed for this panel. If negative, 200 is assumed.

      Parameters:
      minwidth - Whether the panel is sizable.

      Default: 200.

      Returns:
      A modified copy of the this object
    • getBorder

      default String getBorder()
      Returns the border.

      Default: "none".

    • withBorder

      IWindow<I> withBorder(String border)
      Returns a copy of this immutable component with the specified border.

      Sets the border. Allowed values include none (default), and normal For more information, please refer to ZK Component Reference: Window.

      Parameters:
      border - the border. If null, "0" or "false", "none" is assumed.
      Returns:
      A modified copy of the this object
    • withBorder

      default IWindow<I> withBorder(IWindow.Border border)
      Returns a copy of this immutable component with the specified border.

      Sets the border with the given border.

      Parameters:
      border - The border
      Returns:
      A modified copy of the this object
    • isShadow

      default boolean isShadow()
      Returns whether to show the shadow of an overlapped/popup/modal window. It is meaningless if it is an embedded window.

      Default: true

    • withShadow

      IWindow<I> withShadow(boolean shadow)
      Returns a copy of this immutable component with the specified shadow.

      Sets whether to show the shadow of an overlapped/popup/modal window.

      Parameters:
      shadow - Whether to show the shadow of an overlapped/popup/modal window

      Default: true

      Returns:
      A modified copy of the this object
    • isNativeScrollbar

      default boolean isNativeScrollbar()
      Returns whether to use Browser's scrollbar or a floating scrollbar (if with false).

      Default: true to use Browser's scrollbar, if the "org.zkoss.zul.nativebar" library property is not set in zk.xml.

    • withNativeScrollbar

      IWindow<I> withNativeScrollbar(boolean nativeScrollbar)
      Returns a copy of this immutable component with the specified nativeScrollbar.

      Sets to use Browser's scrollbar or a floating scrollbar

      Parameters:
      nativeScrollbar - true to use Browser's scrollbar, or false to use a floating scrollbar.

      Default: true.

      Returns:
      A modified copy of the this object
    • withAllComponents

      default IWindow<I> withAllComponents(Iterable<? extends IAnyGroup> elements)
      Description copied from interface: IComposite
      Copy the current immutable object with elements that replace the content of children. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Specified by:
      withAllComponents in interface IComposite<IWindow<I extends IAnyGroup>,IAnyGroup>
      Parameters:
      elements - An iterable of children elements to set
      Returns:
      A modified copy of this object
    • ofVflex

      static <I extends IAnyGroup> IWindow<I> ofVflex(String vflex)
      Returns the instance with the given vflex.
      Parameters:
      vflex - The vertical flex hint.
    • ofTitle

      static <I extends IAnyGroup> IWindow<I> ofTitle(String title)
      Returns the instance with the given title.
      Parameters:
      title - The title of the component.
    • ofCaption

      static <I extends IAnyGroup> IWindow<I> ofCaption(ICaption caption)
      Returns the instance with the given caption.
      Parameters:
      caption - The caption child
    • ofBorder

      static <I extends IAnyGroup> IWindow<I> ofBorder(IWindow.Border border)
      Returns the instance with the given IWindow.Border border.
      Parameters:
      border - The border of the component
    • of

      static <I extends IAnyGroup> IWindow<I> of(Iterable<? extends I> children)
      Returns the instance with the given any group children.
      Parameters:
      children - The children belong to any group
      See Also:
    • of

      static <I extends IAnyGroup> IWindow<I> of(I... children)
      Returns the instance with the given any group children.
      Parameters:
      children - The children belong to any group
      See Also:
    • ofSize

      static <I extends IAnyGroup> IWindow<I> ofSize(String width, String height)
      Returns the instance with the given size, width and height
      Parameters:
      width - The width of the component
      height - The height of the component
    • ofId

      static <I extends IAnyGroup> IWindow<I> ofId(String id)
      Returns the instance with the given id.
      Parameters:
      id - The id to identify this component
    • ofMode

      static <I extends IAnyGroup> IWindow<I> ofMode(IWindow.Mode mode)
      Returns the instance with the given mode.
      Parameters:
      mode - The mode to overlapped, popup, modal, embedded or highlighted