Class DialogPane

java.lang.Object
All Implemented Interfaces:
Styleable, EventTarget

@DefaultProperty("buttonTypes") public class DialogPane extends Pane
DialogPane should be considered to be the root node displayed within a 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 Parent.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:

  1. The 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.
  2. If 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.
  3. If 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.

Since:
JavaFX 8u40
See Also: