Class Panel
- All Implemented Interfaces:
Serializable,Cloneable,Component,Scope,ComponentCtrl,Framable
Window, Panels can only be floated and moved inside its parent
node, which is not using zk.setVParent() function at client side. In other words,
if Panel's parent node is an relative position, the floated panel is only inside
its parent, not the whole page.
The second difference of Window is that Panel is not an independent ID
space (by implementing IdSpace), so the ID of each child can be used
throughout the panel.
Events:
onMove, onOpen, onZIndex, onMaximize, onMinimize, and onClose.
Default getZclass(): z-panel.
- Since:
- 3.5.0
- Author:
- jumperchen
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddToolbar(String name, Toolbar toolbar) Adds the toolbar of the panel by these names, "tbar", "bbar", and "fbar".voidbeforeChildAdded(Component newChild, Component refChild) Default: does nothing.clone()Clones the component.Returns the border.Returns the bottom toolbar of this panel.Returns the caption of this panel.Returns the foot toolbar of this panel.intReturns the minimum height.intReturns the minimum width.Returns the panelchildren of this panel.getTitle()Returns the title.Returns the top toolbar of this panel.Returns the ZK Cascading Style class for this component.booleaninsertBefore(Component newChild, Component refChild) Inserts a child before the reference child.booleanReturns whether to show a close button on the title bar.booleanReturns whether to show a toggle button on the title bar.booleanReturns whether to float the panel to display it inline where it is rendered.booleanReturns whether to display the maximizing button and allow the user to maximize the panel.booleanReturns whether the panel is maximized.booleanReturns whether to display the minimizing button and allow the user to minimize the panel.booleanReturns whether the panel is minimized.booleanReturns whether to move the panel to display it inline where it is rendered.booleanisOpen()Returns whether this Panel is open.booleanReturns whether the panel is sizable.voidonChildRemoved(Component child) Default: handles special event listeners.voidonClose()Process the onClose event sent when the close button is pressed.protected voidrenderProperties(ContentRenderer renderer) Renders the content of this component, excluding the enclosing tags and children.voidProcesses an AU request.voidsetBorder(boolean border) Enables or disables the border.voidSets the border.voidsetClosable(boolean closable) Sets whether to show a close button on the title bar.voidsetCollapsible(boolean collapsible) Sets whether to show a toggle button on the title bar.voidsetFloatable(boolean floatable) Sets whether to float the panel to display it inline where it is rendered.voidsetMaximizable(boolean maximizable) Sets whether to display the maximizing button and allow the user to maximize the panel, when a panel is maximized, the button will automatically change to a restore button with the appropriate behavior already built-in that will restore the panel to its previous size.voidsetMaximized(boolean maximized) Sets whether the panel is maximized, and then the size of the panel will depend on it to show an appropriate size.voidsetMinheight(int minheight) Sets the minimum height in pixels allowed for this panel.voidsetMinimizable(boolean minimizable) Sets whether to display the minimizing button and allow the user to minimize the panel.voidsetMinimized(boolean minimized) Sets whether the panel is minimized.voidsetMinwidth(int minwidth) Sets the minimum width in pixels allowed for this panel.voidsetMovable(boolean movable) Sets whether to move the panel to display it inline where it is rendered.voidsetOpen(boolean open) Opens or closes this Panel.voidsetSizable(boolean sizable) Sets whether the panel is sizable.voidSets the title.booleansetVisible(boolean visible) Sets whether this component is visible.Methods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Constructor Details
-
Panel
public Panel()
-
-
Method Details
-
isOpen
public boolean isOpen()Returns whether this Panel is open.Default: true.
-
setOpen
public void setOpen(boolean open) Opens or closes this Panel. -
setMovable
public void setMovable(boolean movable) Sets whether to move the panel to display it inline where it is rendered.Default: false;
Note that this method only applied when
isFloatable()is true. -
isMovable
public boolean isMovable()Returns whether to move the panel to display it inline where it is rendered.Default: false.
-
isFloatable
public boolean isFloatable()Returns whether to float the panel to display it inline where it is rendered.Default: false.
-
setVisible
public boolean setVisible(boolean visible) Description copied from interface:ComponentSets whether this component is visible. A component is visible by default. Both visible and invisible components are rendered in a browser's DOM. But an invisible component's DOM elements with CSSdisplay:none. Since a DOM element will inherit its parent's CSS rules, a component is visible only if all of its parents are also visible.
To remove a component's DOM elements, useComponent.detach().- Specified by:
setVisiblein interfaceComponent- Overrides:
setVisiblein classAbstractComponent- Returns:
- the previous visibility
-
setFloatable
public void setFloatable(boolean floatable) Sets whether to float the panel to display it inline where it is rendered.Note that by default, setting floatable to true will cause the panel to display at default offsets, which depend on the offsets of the embedded panel from its element to document.body -- because the panel is absolute positioned, the position must be set explicitly by
HtmlBasedComponent.setTop(String)andHtmlBasedComponent.setLeft(String). Also, when floatable a panel you should always assign a fixed width, otherwise it will be auto width and will expand to fill to the right edge of the viewport. -
isMaximized
public boolean isMaximized()Returns whether the panel is maximized.- Specified by:
isMaximizedin interfaceFramable
-
setMaximized
public void setMaximized(boolean maximized) Sets whether the panel is maximized, and then the size of the panel will depend on it to show an appropriate size. In other words, if true, the size of the panel will count on the size of its offset parent node whose position is absolute (byisFloatable()) or its parent node. Otherwise, its size will be original size. Note that the maximized effect will run at client's sizing phase not initial phase.Default: false.
- Throws:
UiException- ifisMaximizable()is false.
-
isMaximizable
public boolean isMaximizable()Returns whether to display the maximizing button and allow the user to maximize the panel.Default: false.
- Specified by:
isMaximizablein interfaceFramable
-
setMaximizable
public void setMaximizable(boolean maximizable) Sets whether to display the maximizing button and allow the user to maximize the panel, when a panel is maximized, the button will automatically change to a restore button with the appropriate behavior already built-in that will restore the panel to its previous size.Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
-
isMinimized
public boolean isMinimized()Returns whether the panel is minimized.Default: false.
-
setMinimized
public void setMinimized(boolean minimized) Sets whether the panel is minimized.Default: false.
- Throws:
UiException- ifisMinimizable()is false.
-
isMinimizable
public boolean isMinimizable()Returns whether to display the minimizing button and allow the user to minimize the panel.Default: false.
- Specified by:
isMinimizablein interfaceFramable
-
setMinimizable
public void setMinimizable(boolean minimizable) Sets whether to display the minimizing button and allow the user to minimize the panel. Note that this button provides no implementation -- the behavior of minimizing a panel is implementation-specific, so the MinimizeEvent event must be handled and a custom minimize behavior implemented for this option to be useful.Default: false.
Note: the maximize button won't be displayed if no title or caption at all.
- See Also:
-
isCollapsible
public boolean isCollapsible()Returns whether to show a toggle button on the title bar.Default: false.
- Specified by:
isCollapsiblein interfaceFramable
-
setCollapsible
public void setCollapsible(boolean collapsible) Sets whether to show a toggle button on the title bar.Default: false.
Note: the toggle button won't be displayed if no title or caption at all.
Note: onOpen event will be sent when you click the toggle button
-
isClosable
public boolean isClosable()Returns whether to show a close button on the title bar.- Specified by:
isClosablein interfaceFramable
-
setClosable
public void setClosable(boolean closable) Sets whether to show a close button on the title bar. If closable, a button is displayed and the onClose event is sent if an user clicks the button.Default: false.
You can intercept the default behavior by either overriding
onClose(), or listening the onClose event.Note: the close button won't be displayed if no title or caption at all.
-
setMinheight
public void setMinheight(int minheight) Sets the minimum height in pixels allowed for this panel. If negative, 100 is assumed.Default: 100.
Note: Only applies when
isSizable()= true.- Since:
- 5.0.0
-
getMinheight
public int getMinheight()Returns the minimum height.Default: 100.
- Since:
- 5.0.0
-
setMinwidth
public void setMinwidth(int minwidth) Sets the minimum width in pixels allowed for this panel. If negative, 200 is assumed.Default: 200.
Note: Only applies when
isSizable()= true.- Since:
- 5.0.0
-
getMinwidth
public int getMinwidth()Returns the minimum width.Default: 200.
- Since:
- 5.0.0
-
isSizable
public boolean isSizable()Returns whether the panel is sizable.- Since:
- 5.0.0
-
setSizable
public void setSizable(boolean sizable) Sets whether the panel is sizable. If true, an user can drag the border to change the panel width.Default: false.
- Since:
- 5.0.0
-
getCaption
Returns the caption of this panel. -
getBorder
Returns the border.Default: "none".
-
setBorder
Sets the border. Allowed values includenone(default),normal. For more information, please refer to ZK Component Reference: Panel.- Parameters:
border- the border. If null, "0" or "false", "none" is assumed. If "true", "normal" is assumed (since 5.0.8).
-
setBorder
public void setBorder(boolean border) Enables or disables the border.- Parameters:
border- whether to have a border. If true is specified, it is the same assetBorder("normal").- Since:
- 5.0.8
-
getTitle
Returns the title. Besides this attribute, you could useCaptionto define a more sophisticated caption (a.k.a., title).If a panel has a caption whose label (
LabelElement.getLabel()) is not empty, then this attribute is ignored.Default: empty.
-
setTitle
Sets the title. -
addToolbar
Adds the toolbar of the panel by these names, "tbar", "bbar", and "fbar". "tbar" is the name of top toolbar, and "bbar" the name of bottom toolbar, and "fbar" the name of foot toolbar.- Parameters:
name- "tbar", "bbar", and "fbar".
-
onClose
public void onClose()Process the onClose event sent when the close button is pressed.Default: detach itself.
-
getTopToolbar
Returns the top toolbar of this panel. -
getBottomToolbar
Returns the bottom toolbar of this panel. -
getFootToolbar
Returns the foot toolbar of this panel. -
getPanelchildren
Returns the panelchildren of this panel. -
getZclass
Description copied from class:HtmlBasedComponentReturns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.getMold()).Default: null (the default value depends on element).
HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value ofHtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, useHtmlBasedComponent.setSclass(java.lang.String)instead.- Overrides:
getZclassin classHtmlBasedComponent- See Also:
-
beforeChildAdded
Description copied from class:AbstractComponentDefault: does nothing.- Specified by:
beforeChildAddedin interfaceComponentCtrl- Overrides:
beforeChildAddedin classAbstractComponent- Parameters:
newChild- the child to be added (never null).refChild- another child component that the new child will be inserted before it. If null, the new child will be the last child.- See Also:
-
insertBefore
Description copied from interface:ComponentInserts a child before the reference child.You could use
Component.setParent(org.zkoss.zk.ui.Component)orComponent.appendChild(org.zkoss.zk.ui.Component)instead of this method, unless you want to control where to put the child.Note:
Component.setParent(org.zkoss.zk.ui.Component)always calls backComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)and/orComponent.removeChild(org.zkoss.zk.ui.Component), whileComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)andComponent.removeChild(org.zkoss.zk.ui.Component)always calls backComponent.setParent(org.zkoss.zk.ui.Component), if the parent is changed. Thus, you don't need to override bothComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)andComponent.setParent(org.zkoss.zk.ui.Component), if you want to customize the behavior.If you would like to monitor if a component is attached or detached from a page, you could register a desktop listener implementing
UiLifeCycle.- Specified by:
insertBeforein interfaceComponent- Overrides:
insertBeforein classAbstractComponent- Parameters:
newChild- the new child to be inserted.refChild- the child before which you want the new child being inserted. If null, the new child is append to the end.- Returns:
- true if newChild is added successfully or moved; false if it already has the specified child and the order doesn't change.
-
onChildRemoved
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onChildRemovedin interfaceComponentCtrl- Overrides:
onChildRemovedin classAbstractComponent- See Also:
-
clone
Description copied from interface:ComponentClones the component. All of its children and descendants are cloned. Also, ID are preserved.- Specified by:
clonein interfaceComponent- Overrides:
clonein classXulElement- Returns:
- the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
-
renderProperties
Description copied from class:HtmlBasedComponentRenders the content of this component, excluding the enclosing tags and children.- Overrides:
renderPropertiesin classXulElement- Throws:
IOException
-
service
Processes an AU request.Default: in addition to what are handled by
HtmlBasedComponent.service(org.zkoss.zk.au.AuRequest, boolean), it also handles onOpen.- Specified by:
servicein interfaceComponentCtrl- Overrides:
servicein classHtmlBasedComponenteverError- whether any error ever occurred before processing this request.- Since:
- 5.0.0
- See Also:
-