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
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Modal window footer componentclass
The modal window header component -
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionCreates an empty modal windowModalWindow
(String id) Creates an empty modal window with specified ID -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component<?> component) Adds the specified component to the modal window contents.addMouseDownHandler
(MouseDownEventHandler handler) Adds a mouse button down event handler to the component.Adds a mouse enter event handler to the component.Adds a mouse leave event handler to the component.addMouseMoveHandler
(MouseMoveEventHandler handler) Adds a mouse move event handler to the component.addMouseOutHandler
(MouseOutEventHandler handler) Adds a mouse out event handler to the component.addMouseOverHandler
(MouseOverEventHandler handler) Adds a mouse over event handler to the component.addMouseUpHandler
(MouseUpEventHandler handler) Adds a mouse up event handler to the component.Adds a mouse wheel event handler to the component.addScrollHandler
(ScrollEventHandler handler) Adds a Scroll event handler to the component.addTitleComponent
(Component<?> component) Adds a component to the title of the modal window.Gets the modal window footer componentGets the modal window header componenthide()
Hides the modal window from the interface.void
init()
The component initialization method.boolean
Determines if the window can be closed by pressing the ESC button.boolean
isModal()
Determines if the window is modal.boolean
Sets if a window can be resized.removeComponent
(Component<?> component) Removes the specified component from the modal window contents.setCloseWithESC
(boolean closeWithESC) If set, the modal window can be closed by pressing the ESC button.setHeaderIcon
(Icon icon) Sets the modal window header iconSets the height of the modal window.setModal
(boolean modal) Sets the window to be modal.setResizeable
(boolean resizeable, int minWidth, int minHeight) Sets if a window can be resized.setShowFooter
(boolean showFooter) Sets the footer to be displayed.setShowHeader
(boolean showHeader) Sets the header to be displayed.Sets the modal window header textSets the width of the modal window.show()
Shows the modal window on the interface.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
-
Constructor Details
-
ModalWindow
public ModalWindow()Creates an empty modal window -
ModalWindow
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
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 classComponent<ModalWindow>
- Throws:
JavaScriptLoadError
- If there was a JavaScript error during the initialization.
-
setHeaderIcon
Sets the modal window header icon- Parameters:
icon
- The icon that will be used. For the usable icons, see theIcon
enum.- Returns:
- The modal window
-
setTitle
Sets the modal window header text- Parameters:
text
- The modal window header text- Returns:
- The modal window
-
addTitleComponent
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
Sets the header to be displayed. Defaults to true.- Parameters:
showHeader
- Iftrue
the header is shown, otherwise the header will not be shown.- Returns:
- The modal window
-
getHeader
Gets the modal window header component- Returns:
- The modal window header component
-
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
Hides the modal window from the interface.- Returns:
- The modal window
-
setWidth
Sets the width of the modal window.- Parameters:
width
- The width, specified in pixel or percent- Returns:
- The modal window
-
setHeight
Sets the height of the modal window.- Parameters:
height
- The height, specified in pixel or precent- Returns:
- The modal window
-
addComponent
Adds the specified component to the modal window contents.- Overrides:
addComponent
in classComponent<ModalWindow>
- Parameters:
component
- The component to be added- Returns:
- The component
-
removeComponent
Removes the specified component from the modal window contents.- Overrides:
removeComponent
in classComponent<ModalWindow>
- Parameters:
component
- The component instance- Returns:
- The component
-
setCloseWithESC
If set, the modal window can be closed by pressing the ESC button. By default, this is enabled.- Parameters:
closeWithESC
- Iftrue
, 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, otherwisefalse
-
setModal
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
- Iftrue
, the window will be modal, meaning it won't close if the user clicks outside it. Iffalse
, 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, otherwisefalse
.
-
setResizeable
Sets if a window can be resized. By default, a window cannot be resized.- Parameters:
resizeable
- Iftrue
is specified, the user is allowed to resize the windowminWidth
- 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
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 interfaceScrollable<ModalWindow>
- Parameters:
handler
- TheScrollEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseDownHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseDownEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseEnterHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseEnterEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseLeaveHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseLeaveEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseMoveHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseMoveEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseOverHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseOverEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseOutHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseOutEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseUpHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseUpEventHandler
implementation- Returns:
- The component
- See Also:
-
addMouseWheelHandler
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 interfaceHandleMouseEvents<ModalWindow>
- Parameters:
handler
- TheMouseWheelEventHandler
implementation- Returns:
- The component
- See Also:
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis 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 withfalse
. Otherwise, it must return withtrue
.- Specified by:
writeHTML
in classComponent<ModalWindow>
- Returns:
- If the componentwas drawn,
true
, otherwisefalse
-