@DefaultProperty(value="buttonTypes") public class DialogPane extends Pane
Dialog
instance. In this role, the DialogPane is responsible for the
placement of headers
, graphics
,
content
, and buttons
.
The default implementation of DialogPane (that is, the DialogPane class itself)
handles the layout via the normal layoutChildren()
method. This
method may be overridden by subclasses wishing to handle the layout in an
alternative fashion).
In addition to the header
and
content
properties, there exists
header text
and
content text
properties. The way the *Text
properties work is that they are a lower precedence compared to the Node
properties, but they are far more convenient for developers in the common case,
as it is likely the case that a developer more often than not simply wants to
set a string value into the header or content areas of the DialogPane.
It is important to understand the implications of setting non-null values
in the header
and headerText
properties. The key points are as follows:
header
property takes precedence over the headerText
property, so if both are set to non-null values, header
will be
used and headerText
will be ignored.headerText
is set to a non-null value, and a
graphic
has also been set, the default position
for the graphic shifts from being located to the left of the content area
to being to the right of the header text.header
is set to a non-null value, and a
graphic
has also been set, the graphic is
removed from its default position (to the left of the content area),
and is not placed to the right of the custom header
node. If the graphic is desired, it should be manually added in to the
layout of the custom header node manually.DialogPane operates on the concept of ButtonType
. A ButtonType is
a descriptor of a single button that should be represented visually in the
DialogPane. Developers who create a DialogPane therefore must specify the
button types that they want to display, and this is done via the
getButtonTypes()
method, which returns a modifiable
ObservableList
, which users can add to and remove from as desired.
The ButtonType
class defines a number of pre-defined button types,
such as ButtonType.OK
and ButtonType.CANCEL
. Many users of the
JavaFX dialogs API will find that these pre-defined button types meet their
needs, particularly due to their built-in support for
default
and
cancel
buttons, as well as the benefit of
the strings being translated into all languages which JavaFX is translated to.
For users that want to define their own ButtonType
(most commonly to
define a button with custom text), they may do so via the constructors available
on the ButtonType
class.
Developers will quickly find that the amount of configurability offered
via the ButtonType
class is minimal. This is intentional, but does not
mean that developers can not modify the buttons created by the ButtonType
that have been specified. To do this, developers simply call the
lookupButton(ButtonType)
method with the ButtonType (assuming it has
already been set in the getButtonTypes()
list. The returned Node is
typically of type Button
, but this depends on if the
createButton(ButtonType)
method has been overridden.
The DialogPane class offers a few methods that can be overridden by subclasses, to more easily enable custom functionality. These methods include the following:
These methods are documented, so please take note of the expectations placed on any developer who wishes to override these methods with their own functionality.
Dialog
Type | Property and Description |
---|---|
ObjectProperty<Node> |
content
Property representing the content area of the dialog.
|
StringProperty |
contentText
A property representing the content text for the dialog pane.
|
ObjectProperty<Node> |
expandableContent
A property that represents the dialog expandable content area.
|
BooleanProperty |
expanded
Represents whether the dialogPane is expanded.
|
ObjectProperty<Node> |
graphic
The dialog graphic, presented either in the header, if one is showing, or
to the left of the
content . |
ObjectProperty<Node> |
header
Property representing the header area of the dialog pane.
|
StringProperty |
headerText
A property representing the header text for the dialog pane.
|
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
needsLayout
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
DialogPane()
Creates a new DialogPane instance with a style class of 'dialog-pane'.
|
Modifier and Type | Method and Description |
---|---|
protected double |
computeMinHeight(double width)
Computes the minimum height of this region.
|
protected double |
computeMinWidth(double height)
Computes the minimum width of this region.
|
protected double |
computePrefHeight(double width)
Computes the preferred height of this region for the given width;
Region subclasses should override this method to return an appropriate
value based on their content and layout strategy.
|
protected double |
computePrefWidth(double height)
Computes the preferred width of this region for the given height.
|
ObjectProperty<Node> |
contentProperty()
Property representing the content area of the dialog.
|
StringProperty |
contentTextProperty()
A property representing the content text for the dialog pane.
|
protected Node |
createButton(ButtonType buttonType)
This method can be overridden by subclasses to create a custom button that
will subsequently inserted into the DialogPane button area (created via
the
createButtonBar() method, but mostly commonly it is an instance
of ButtonBar . |
protected Node |
createButtonBar()
This method can be overridden by subclasses to provide the button bar.
|
protected Node |
createDetailsButton()
This method can be overridden by subclasses to create a custom details button.
|
ObjectProperty<Node> |
expandableContentProperty()
A property that represents the dialog expandable content area.
|
BooleanProperty |
expandedProperty()
Represents whether the dialogPane is expanded.
|
ObservableList<ButtonType> |
getButtonTypes()
Observable list of button types used for the dialog button bar area
(created via the
createButtonBar() method). |
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
Node |
getContent()
Returns the dialog content as a Node (even if it was set as a String
using
setContentText(String) - this was simply transformed into a
Node (most probably a Label ). |
String |
getContentText()
Returns the currently-set content text for this DialogPane.
|
List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
This method should delegate to
Node.getClassCssMetaData() so that
a Node's CssMetaData can be accessed without the need for reflection. |
Node |
getExpandableContent()
Returns the dialog expandable content node, if one is set, or null
otherwise.
|
Node |
getGraphic()
Gets the value of the property graphic.
|
Node |
getHeader()
Node which acts as the dialog pane header.
|
String |
getHeaderText()
Returns the currently-set header text for this DialogPane.
|
ObjectProperty<Node> |
graphicProperty()
The dialog graphic, presented either in the header, if one is showing, or
to the left of the
content . |
ObjectProperty<Node> |
headerProperty()
Property representing the header area of the dialog pane.
|
StringProperty |
headerTextProperty()
A property representing the header text for the dialog pane.
|
boolean |
isExpanded()
Returns whether or not the dialogPane is expanded.
|
protected void |
layoutChildren()
Invoked during the layout pass to layout the children in this
Parent . |
Node |
lookupButton(ButtonType buttonType)
This method provides a way in which developers may retrieve the actual
Node for a given
ButtonType (assuming it is part of the
button types list). |
void |
setContent(Node content)
Assign dialog content.
|
void |
setContentText(String contentText)
Sets the string to show in the dialog content area.
|
void |
setExpandableContent(Node content)
Sets the dialog expandable content node, or null if no expandable content
needs to be shown.
|
void |
setExpanded(boolean value)
Sets whether the dialogPane is expanded.
|
void |
setGraphic(Node graphic)
Sets the dialog graphic, which will be displayed either in the header, if
one is showing, or to the left of the
content . |
void |
setHeader(Node header)
Assigns the dialog pane header.
|
void |
setHeaderText(String headerText)
Sets the string to show in the dialog header area.
|
getChildren
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public final ObjectProperty<Node> graphicProperty
content
.getGraphic()
,
setGraphic(Node)
public final ObjectProperty<Node> headerProperty
DialogPane
class
javadoc.getHeader()
,
setHeader(Node)
public final StringProperty headerTextProperty
header node
, meaning
that if both the header node and the headerText properties are set, the
header text will not be displayed in a default DialogPane instance.
When headerText is set to a non-null value, this will result in the
DialogPane switching its layout to the 'header' layout - as outlined in
the DialogPane
class javadoc.
getHeaderText()
,
setHeaderText(String)
public final ObjectProperty<Node> contentProperty
getContent()
,
setContent(Node)
public final StringProperty contentTextProperty
content node
, meaning
that if both the content node and the contentText properties are set, the
content text will not be displayed in a default DialogPane instance.getContentText()
,
setContentText(String)
public final ObjectProperty<Node> expandableContentProperty
getExpandableContent()
,
setExpandableContent(Node)
public final BooleanProperty expandedProperty
isExpanded()
,
setExpanded(boolean)
public DialogPane()
public final ObjectProperty<Node> graphicProperty()
content
.getGraphic()
,
setGraphic(Node)
public final Node getGraphic()
content
.public final void setGraphic(Node graphic)
content
.graphic
- The new dialog graphic, or null if no graphic should be shown.public final Node getHeader()
public final void setHeader(Node header)
header
- The new header of the DialogPane.public final ObjectProperty<Node> headerProperty()
DialogPane
class
javadoc.getHeader()
,
setHeader(Node)
public final void setHeaderText(String headerText)
header node
, meaning
that if both the header node and the headerText properties are set, the
header text will not be displayed in a default DialogPane instance.
When headerText is set to a non-null value, this will result in the
DialogPane switching its layout to the 'header' layout - as outlined in
the DialogPane
class javadoc.
public final String getHeaderText()
public final StringProperty headerTextProperty()
header node
, meaning
that if both the header node and the headerText properties are set, the
header text will not be displayed in a default DialogPane instance.
When headerText is set to a non-null value, this will result in the
DialogPane switching its layout to the 'header' layout - as outlined in
the DialogPane
class javadoc.
getHeaderText()
,
setHeaderText(String)
public final Node getContent()
setContentText(String)
- this was simply transformed into a
Node
(most probably a Label
).public final void setContent(Node content)
content
- dialog's contentpublic final ObjectProperty<Node> contentProperty()
getContent()
,
setContent(Node)
public final void setContentText(String contentText)
content node
, meaning
that if both the content node and the contentText properties are set, the
content text will not be displayed in a default DialogPane instance.public final String getContentText()
public final StringProperty contentTextProperty()
content node
, meaning
that if both the content node and the contentText properties are set, the
content text will not be displayed in a default DialogPane instance.getContentText()
,
setContentText(String)
public final ObjectProperty<Node> expandableContentProperty()
getExpandableContent()
,
setExpandableContent(Node)
public final Node getExpandableContent()
public final void setExpandableContent(Node content)
public final BooleanProperty expandedProperty()
isExpanded()
,
setExpanded(boolean)
public final boolean isExpanded()
public final void setExpanded(boolean value)
expandable content
to show.value
- true if dialogPane should be expanded.public final ObservableList<ButtonType> getButtonTypes()
createButtonBar()
method). Modifying the contents
of this list will immediately change the buttons displayed to the user
within the dialog pane.ObservableList
of button types
available to the user.public final Node lookupButton(ButtonType buttonType)
ButtonType
(assuming it is part of the
button types
list).buttonType
- The ButtonType
for which a Node representation is requested.createButton(ButtonType)
, and only if the button type
is part of the button types
list, otherwise null.protected Node createButtonBar()
button types
and call
createButton(ButtonType)
for each of them in turn.
button types
list, and when this list changes
update the button bar as appropriate.
expandable content
property,
adding and removing the details button (created via
createDetailsButton()
method).
The default implementation of this method creates and returns a new
ButtonBar
instance.
protected Node createButton(ButtonType buttonType)
createButtonBar()
method, but mostly commonly it is an instance
of ButtonBar
.buttonType
- The ButtonType
to create a button from.Node
that represents the given ButtonType
,
most commonly an instance of Button
.protected Node createDetailsButton()
To override this method you must do two things:
expanded
property.
expanded
property, so that you may update
the button visuals.
protected void layoutChildren()
Parent
. By default it will only set the size of managed,
resizable content to their preferred sizes and does not do any node
positioning.
Subclasses should override this function to layout content as needed.
layoutChildren
in class Parent
protected double computeMinWidth(double height)
computeMinWidth
in class Region
height
- the height that should be used if min width depends
on itprotected double computeMinHeight(double width)
computeMinHeight
in class Region
width
- the width that should be used if min height depends
on itprotected double computePrefWidth(double height)
computePrefWidth
in class Region
height
- the height that should be used if preferred width depends
on itprotected double computePrefHeight(double width)
computePrefHeight
in class Region
width
- the width that should be used if preferred height depends
on itpublic static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.getCssMetaData
in interface Styleable
getCssMetaData
in class Region
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.