java.lang.Object
de.seggebaeing.sqlanalyzer.presentation.util.UIUtil

public class UIUtil extends Object
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 Type
    Method
    Description
    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 JavaFX Alert 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 range min <= max.
    static void
    initIntegerField(javafx.scene.control.TextField field)
    Restricts a TextField 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 a ComboBox's popup after its items changed so the dropdown recomputes cell sizes/minimum width.
    static void
    showToast(javafx.stage.Stage ownerStage, String message, double durationMillis)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • showToast

      public static void showToast(javafx.stage.Stage ownerStage, String message, double durationMillis)
      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 be null
      message - the text to show
      durationMillis - duration to display in milliseconds; non-positive values hide immediately
      Throws:
      NullPointerException - if ownerStage is null
      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 be null
      label - the label to reflect the slider value; must not be null
      value - initial slider value in [0,1]
      Throws:
      NullPointerException - if slider or label is null
      IllegalArgumentException - if value 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 range min <= 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 be null
      maxSlider - the upper-bound slider; must not be null
      minLabel - label reflecting minSlider's value; must not be null
      maxLabel - label reflecting maxSlider's value; must not be null
      Throws:
      NullPointerException - if any argument is null
      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 be null
      Throws:
      NullPointerException - if node is null
      Implementation Note:
      Uses a one-shot Timeline with KeyFrames 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 a TextField 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 be null
      Throws:
      NullPointerException - if field is null
      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 a ComboBox'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 be null
      Throws:
      NullPointerException - if comboBox is null
      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 JavaFX Alert with title, header, content text, and optional custom buttons.
      Parameters:
      type - the alert type determining default icon and behavior
      title - the window title (may be null)
      header - the header text (use null to hide the header)
      content - the message body text (may be null)
      buttons - optional button types; if none provided, the type’s defaults are used
      Returns:
      the configured Alert; call show() or showAndWait() to display it
      See Also:
      • Alert(Alert.AlertType, String, ButtonType...)