public class Ack
extends javafx.stage.Stage
implements javafx.event.EventHandler
Every dialogue must have one "default" Button, and one "Cancel" button, and if this is not configured ahead of time then the "default" Button will be chosen automatically as the first Button in the array, and the "cancel" Button will be chosen automatically as the last Button in the array), which is a convenience for developers (if there is only one Button, then it will be configured automatically to serve in both the "default" and "cancel" roles).
Mnemonics are also handled as accelerator keys in a case-insensitive manner in this dialogue to make the interface more user-friendly.
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_IMAGE_ICON
Bit flags 1 and 2 (value=1+2) are the Image Alignment bits, which provide
additional information about where to locate the image.
|
static int |
FLAG_IMAGE_LEFT
Bit flags 1 and 2 (value=1+2) are the Image Alignment bits, which provide
additional information about where to locate the image.
|
static int |
FLAG_IMAGE_RIGHT
Bit flags 1 and 2 (value=1+2) are the Image Alignment bits, which provide
additional information about where to locate the image.
|
static int |
FLAG_IMAGE_TOP
Bit flags 1 and 2 (value=1+2) are the Image Alignment bits, which provide
additional information about where to locate the image.
|
static int |
FLAG_MNEMONICS_OFF
Bit flag 3 (value=4) is the Mnemonics bit, and it indicates that each
Button created dynamically from a String should be parsed for a corresponding
Mnemonic, which is the first character prefixed by an underscore ("_").
|
static int |
FLAG_MNEMONICS_ON
Bit flag 3 (value=4) is the Mnemonics bit, and it indicates that each
Button created dynamically from a String should be parsed for a corresponding
Mnemonic, which is the first character prefixed by an underscore ("_").
|
static int |
FLAG_NO_ACCELERATOR
Bit flag 4 (value=8) is the Mnemonics_No_Accelerator bit, and it disables
the default behaviour of treating Mnemonics as Accelerator keys.
|
static int |
FLAG_NODE_FIRST
Bit flag 5 (value=16) is the Node_First bit, which causes the prompt Node
to be added to the dialogue before the Button nodes so that any control nodes
can obtain the keyboard focus first. Internally we add the Button nodes
first so that the "default" Button can obtain the focus first.
|
Constructor and Description |
---|
Ack()
Default constructor for the Acknowledgement dialogue (sets the Window's
title to "Confirmation" and the prompt to "Are you sure?" with the buttons
"Yes" and "No").
|
Ack(String prompt,
javafx.scene.control.Button... b)
Default constructor for the Acknowledgement dialogue.
|
Ack(String prompt,
int flags,
javafx.scene.control.Button... b)
Default constructor for the Acknowledgement dialogue.
|
Ack(String title,
javafx.scene.Node prompt,
javafx.scene.control.Button... b)
Constructor for the Acknowledgement dialogue.
|
Ack(String title,
javafx.scene.Node prompt,
int flags,
javafx.scene.image.ImageView img,
javafx.scene.control.Button... b)
Constructor for the Acknowledgement dialogue.
|
Ack(String title,
javafx.scene.Node prompt,
int flags,
String... s)
Default constructor for the Acknowledgement dialogue.
|
Ack(String title,
String prompt,
javafx.scene.control.Button... b)
Constructor for the Acknowledgement dialogue.
|
Ack(String title,
String prompt,
int flags,
javafx.scene.image.ImageView img,
javafx.scene.control.Button... b)
Constructor for the Acknowledgement dialogue.
|
Ack(String title,
String prompt,
int flags,
String... s)
Default constructor for the Acknowledgement dialogue.
|
Modifier and Type | Method and Description |
---|---|
int |
getSelectedIndex()
Indicates which Button was activated (or -1 if a Button was not activated).
|
javafx.scene.control.Button |
getSelectedItem()
Indicates which Button was activated (or NULL if a Button was not
activated).
|
void |
handle(javafx.event.Event e)
WindowEvent handler (e.g., WINDOW_CLOSE_REQUEST, etc.).
|
void |
handleButton(javafx.event.Event e)
Button event handler.
|
void |
handleKeyTyped(javafx.event.Event e)
Keystroke event handler. Custom Node objects that normally consume
the Enter and Escape keystrokes when they shouldn't (such as the TableView
class does) can be configured as follows to check for these keystrokes:
|
Ack |
setStatusBar(javafx.scene.Node node)
Defines a status bar Node to the bottom of the dialogue, which extends all
the way to the edges (it consumes the normally-empty borders).
|
int |
showAndAwait()
Show dialogue and then await user interaction events.
|
alwaysOnTopProperty, close, fullScreenExitHintProperty, fullScreenExitKeyProperty, fullScreenProperty, getFullScreenExitHint, getFullScreenExitKeyCombination, getIcons, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getModality, getOwner, getStyle, getTitle, iconifiedProperty, impl_getMXWindowType, impl_setImportant, impl_setPrimary, impl_visibleChanged, impl_visibleChanging, initModality, initOwner, initStyle, isAlwaysOnTop, isFullScreen, isIconified, isMaximized, isResizable, maxHeightProperty, maximizedProperty, maxWidthProperty, minHeightProperty, minWidthProperty, resizableProperty, setAlwaysOnTop, setFullScreen, setFullScreenExitHint, setFullScreenExitKeyCombination, setIconified, setMaxHeight, setMaximized, setMaxWidth, setMinHeight, setMinWidth, setResizable, setScene, setTitle, show, showAndWait, titleProperty, toBack, toFront
addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getProperties, getScene, getUserData, getWidth, getX, getY, hasProperties, heightProperty, hide, impl_getPeer, impl_getWindows, isFocused, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, removeEventFilter, removeEventHandler, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setFocused, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setUserData, setWidth, setX, setY, showingProperty, sizeToScene, widthProperty, xProperty, yProperty
public static final int FLAG_IMAGE_ICON
This flag indicates that the image should be treated as an icon, and is to be displayed to the left of the prompt, above the row of buttons.
Note: This is the default.
public static final int FLAG_IMAGE_LEFT
This flag indicates that the image should be treated as a vertical banner, and is to be displayed to the left of the prompt and the buttons.
public static final int FLAG_IMAGE_RIGHT
This flag indicates that the image should be treated as a vertical banner, and is to be displayed to the right of the prompt and the buttons.
public static final int FLAG_IMAGE_TOP
This flag indicates that the image should be treated as a banner, and is to be displayed above the prompt.
public static final int FLAG_MNEMONICS_OFF
Note: This is the default.
public static final int FLAG_MNEMONICS_ON
public static final int FLAG_NO_ACCELERATOR
public static final int FLAG_NODE_FIRST
public Ack()
public Ack(String prompt, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
Mnemonics will be enabled by default.
prompt
- Title for window and text for the promptb
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String prompt, int flags, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
prompt
- Title for window and text for the promptflags
- Use Ack.FLAG_MNEMONICS_ON to parse for the Mnemonic
character ("_"), or Ack.FLAG_MNEMONICS_OFF (or 0) not tob
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String title, javafx.scene.Node prompt, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
Mnemonics will be enabled by default.
title
- Title for windowprompt
- Node for promptb
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String title, javafx.scene.Node prompt, int flags, javafx.scene.image.ImageView img, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
The ImageView object is optional (null == no image), and will display on the left-hand side of the prompt.
title
- Title for windowprompt
- Node for promptflags
- The defaults obtain by specifying 0 should satisfy the majority
of uses; review the Ack.Constants class for additional optionsimg
- ImageView (image/icon) to include in dialogue (null == no image)b
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String title, javafx.scene.Node prompt, int flags, String... s)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
title
- Title for windowprompt
- Node for promptflags
- Use Ack.FLAG_MNEMONICS_ON to parse for the Mnemonic
character ("_"), or Ack.FLAG_MNEMONICS_OFF (or 0) not tos
- Any number of Strings to convert into Button objects (if no buttons
are specified, then the two default "Yes" and "No" buttons will be provided
by default)public Ack(String title, String prompt, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
Mnemonics will be enabled by default.
title
- Title for windowprompt
- Text for prompt (may contain multiple lines)b
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String title, String prompt, int flags, javafx.scene.image.ImageView img, javafx.scene.control.Button... b)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
The ImageView object is optional (null == no image), and will display on the left-hand side of the prompt.
title
- Title for windowprompt
- Text for prompt (may contain multiple lines)flags
- The defaults obtain by specifying 0 should satisfy the majority
of uses; review the Ack.Constants class for additional optionsimg
- ImageView (image/icon) to include in dialogue (null == no image)b
- Any number of buttons (if no buttons are specified, then the
two default "Yes" and "No" buttons will be provided by default)public Ack(String title, String prompt, int flags, String... s)
Any number of Button objects may be provided. If none are pre-set to be the default button, then the first one will be set automatically. If none are pre-set to be the cancel button, then the last one will be set automatically.
title
- Title for windowprompt
- Text for prompt (may contain multiple lines)flags
- Use Ack.FLAG_MNEMONICS_ON to parse for the Mnemonic
character ("_"), or Ack.FLAG_MNEMONICS_OFF (or 0) not tos
- Any number of Strings to convert into Button objects (if no buttons
are specified, then the two default "Yes" and "No" buttons will be provided
by default)public int getSelectedIndex()
Note: If the dialogue was closed without using one of the Button objects, then whichever Button was designated as the "Cancel" will be activated automatically, and consequently reflected in the returned value.
public javafx.scene.control.Button getSelectedItem()
public void handle(javafx.event.Event e)
handle
in interface javafx.event.EventHandler
e
- Event objectpublic void handleButton(javafx.event.Event e)
e
- Event objectpublic void handleKeyTyped(javafx.event.Event e)
tableViewNode.setOnKeyTyped(ack::handleKeyTyped);
e
- Event objectpublic Ack setStatusBar(javafx.scene.Node node)
node
- JavaFX Node that presents the optional status bar (set to NULL to
remove; underlying grid output may be unpredictable because this dialogue
isn't intended for long-term use)public int showAndAwait()
The index returned represents the position of the Button that was activated by the end-user, starting from 0.
Note: If the dialogue was closed without using one of the Button objects, then whichever Button was designated as the "Cancel" will be activated automatically, and consequently reflected in the returned value.
Note: The spelling is "await" rather than "wait" because Java doesn't permit overriding methods when the return value is not "void."