java.lang.Object
de.seggebaeing.sqlanalyzer.presentation.util.UIUtil
Collection of lightweight JavaFX UI utilities for views and controllers.
Offers helpers for transient notifications, basic input constraints,
simple control initialization, and visual feedback. Stateless; call on
the JavaFX Application Thread when mutating controls.
- Since:
- 1.0
- Author:
- Felix Seggebäing
-
Method Summary
Modifier and TypeMethodDescriptionstatic javafx.scene.control.Alert
generateAlert
(javafx.scene.control.Alert.AlertType type, String title, String header, String content, javafx.scene.control.ButtonType... buttons) Creates a configured JavaFXAlert
with title, header, content text, and optional custom buttons.static void
initBoundedSliders
(javafx.scene.control.Slider minSlider, javafx.scene.control.Slider maxSlider, javafx.scene.control.Label minLabel, javafx.scene.control.Label maxLabel) Initializes two coupled sliders representing a bounded rangemin <= max
.static void
initIntegerField
(javafx.scene.control.TextField field) Restricts aTextField
to digits only by filtering its text on change.static void
initSlider
(javafx.scene.control.Slider slider, javafx.scene.control.Label label, double value) Initializes a slider in the range[0.0, 1.0]
with the given initial value, configures a small block increment, and keeps the label in sync with the current slider value formatted to two decimals.static <T> void
resetComboBox
(javafx.scene.control.ComboBox<T> comboBox) Triggers a full re-render of aComboBox
's popup after its items changed so the dropdown recomputes cell sizes/minimum width.static void
Displays a lightweight toast popup centered near the bottom of the given stage for the specified duration.static void
signalBorder
(javafx.scene.Node node) Briefly emphasizes a node by flashing a red border for ~1 second, then clearing its inline style.
-
Method Details
-
showToast
Displays a lightweight toast popup centered near the bottom of the given stage for the specified duration. The popup auto-fixes/auto-hides and uses a simple rounded white container.- Parameters:
ownerStage
- the stage to anchor and position against; must not benull
message
- the text to showdurationMillis
- duration to display in milliseconds; non-positive values hide immediately- Throws:
NullPointerException
- ifownerStage
isnull
- Implementation Note:
- Invoke on the JavaFX Application Thread.
-
initSlider
public static void initSlider(javafx.scene.control.Slider slider, javafx.scene.control.Label label, double value) Initializes a slider in the range[0.0, 1.0]
with the given initial value, configures a small block increment, and keeps the label in sync with the current slider value formatted to two decimals.- Parameters:
slider
- the slider to configure; must not benull
label
- the label to reflect the slider value; must not benull
value
- initial slider value in[0,1]
- Throws:
NullPointerException
- ifslider
orlabel
isnull
IllegalArgumentException
- ifvalue
is outside[0,1]
- Implementation Note:
- Invoke on the JavaFX Application Thread.
-
initBoundedSliders
public static void initBoundedSliders(javafx.scene.control.Slider minSlider, javafx.scene.control.Slider maxSlider, javafx.scene.control.Label minLabel, javafx.scene.control.Label maxLabel) Initializes two coupled sliders representing a bounded rangemin <= max
. Sets defaults (min=0.70
,max=0.80
), binds labels to current values, and enforces the invariant by clamping when one slider crosses the other.- Parameters:
minSlider
- the lower-bound slider; must not benull
maxSlider
- the upper-bound slider; must not benull
minLabel
- label reflectingminSlider
's value; must not benull
maxLabel
- label reflectingmaxSlider
's value; must not benull
- Throws:
NullPointerException
- if any argument isnull
- Implementation Note:
- Invoke on the JavaFX Application Thread.
-
signalBorder
public static void signalBorder(javafx.scene.Node node) Briefly emphasizes a node by flashing a red border for ~1 second, then clearing its inline style.- Parameters:
node
- the node to emphasize; must not benull
- Throws:
NullPointerException
- ifnode
isnull
- Implementation Note:
- Uses a one-shot
Timeline
withKeyFrame
s to toggle the border; invoke on the JavaFX Application Thread. Previous inline styles are discarded when the style is cleared at the end.
-
initIntegerField
public static void initIntegerField(javafx.scene.control.TextField field) Restricts aTextField
to digits only by filtering its text on change. Non-digit characters are removed in place as the user types (no sign or decimals).- Parameters:
field
- the text field to constrain; must not benull
- Throws:
NullPointerException
- iffield
isnull
- Implementation Note:
- Adds a listener to
textProperty()
and mutates the field’s text. Invoke on the JavaFX Application Thread.
-
resetComboBox
public static <T> void resetComboBox(javafx.scene.control.ComboBox<T> comboBox) Triggers a full re-render of aComboBox
's popup after its items changed so the dropdown recomputes cell sizes/minimum width. Preserves the current selection.- Parameters:
comboBox
- the combo box to refresh; must not benull
- Throws:
NullPointerException
- ifcomboBox
isnull
- Implementation Note:
- Swaps the items list to force a skin refresh, then restores items and value. Invoke on the JavaFX Application Thread.
-
generateAlert
public static javafx.scene.control.Alert generateAlert(javafx.scene.control.Alert.AlertType type, String title, String header, String content, javafx.scene.control.ButtonType... buttons) Creates a configured JavaFXAlert
with title, header, content text, and optional custom buttons.- Parameters:
type
- the alert type determining default icon and behaviortitle
- the window title (may benull
)header
- the header text (usenull
to hide the header)content
- the message body text (may benull
)buttons
- optional button types; if none provided, the type’s defaults are used- Returns:
- the configured
Alert
; callshow()
orshowAndWait()
to display it - See Also:
-