Class Fx

java.lang.Object
org.tentackle.fx.Fx

public class Fx extends Object
Often used factory and helper methods for FX-related stuff.
Author:
harald
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, R extends T>
    R
    create(Class<T> clazz)
    Creates an object.
    FX objects should not be created via the builder factory and not the traditional way by invoking a constructor.
    static javafx.scene.Node
    Creates the graphic node for a given name and the default realm.
    Throws IllegalArgumentException if no such icon.
    static javafx.scene.Node
    createGraphic(String realm, String name)
    Creates the graphic node for a given realm and name.
    Throws IllegalArgumentException if no such icon and/or realm.
    static javafx.scene.Scene
    createScene(javafx.scene.Parent root)
    Creates a scene.
    static javafx.stage.Stage
    createStage(javafx.stage.Modality modality)
    Creates a new decorated stage.
    Tentackle applications should use this factory method instead of new Stage() because the stage will be configured to meet certain framework-wide conventions.
    static javafx.stage.Stage
    createStage(javafx.stage.StageStyle stageStyle, javafx.stage.Modality modality)
    Creates a new stage.
    Tentackle applications should use this factory method instead of new Stage() because the stage will be configured to meet certain framework-wide conventions.
    static void
    error(Object owner, String message)
    Shows an error dialog.
    static void
    error(Object owner, String message, Throwable t)
    Shows an error dialog.
    static void
    error(Object owner, String message, Throwable t, Runnable onClose)
    Shows an error dialog.
    static javafx.stage.Stage
    getStage(javafx.scene.Node node)
    Gets the stage for a node.
    static void
    info(Object owner, String message)
    Shows an info dialog.
    static void
    info(Object owner, String message, Runnable onClose)
    Shows an info dialog.
    static boolean
    isModal(javafx.stage.Stage stage)
    Returns whether the stage is modal.
    static <T extends FxController>
    T
    load(Class<T> controllerClass)
    Loads a controller with its FXML-view.
    static <T> T
    load(URL location)
    Loads an object hierarchy from a FXML document.
    static <T> T
    load(URL location, ResourceBundle resources)
    Loads an object hierarchy from a FXML document.
    static void
    no(Object owner, String message, boolean defaultYes, Runnable no)
    Shows a question dialog.
    Short for question(Object, String, boolean, Consumer) if answer is only checked for no.
    static void
    question(Object owner, String message, boolean defaultYes, Consumer<Boolean> answer)
    Shows a question dialog.
    static void
    Terminates the FX client.
    static void
    warning(Object owner, String message)
    Shows a warning dialog.
    static void
    warning(Object owner, String message, Runnable onClose)
    Shows a warning dialog.
    static void
    yes(Object owner, String message, boolean defaultYes, Runnable yes)
    Shows a question dialog.
    Short for question(Object, String, boolean, Consumer) if answer is only checked for yes.

    Methods inherited from class java.lang.Object

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

    • load

      public static <T> T load(URL location) throws IOException
      Loads an object hierarchy from a FXML document.
      Type Parameters:
      T - the object's type
      Parameters:
      location - the url
      Returns:
      the object
      Throws:
      IOException - if loading failed
    • load

      public static <T> T load(URL location, ResourceBundle resources) throws IOException
      Loads an object hierarchy from a FXML document.
      Type Parameters:
      T - the object's type
      Parameters:
      location - the url
      resources - the optional resources
      Returns:
      the object
      Throws:
      IOException - if loading failed
    • load

      public static <T extends FxController> T load(Class<T> controllerClass)
      Loads a controller with its FXML-view.
      Type Parameters:
      T - the controller type
      Parameters:
      controllerClass - the controller class
      Returns:
      the controller
    • createStage

      public static javafx.stage.Stage createStage(javafx.stage.StageStyle stageStyle, javafx.stage.Modality modality)
      Creates a new stage.
      Tentackle applications should use this factory method instead of new Stage() because the stage will be configured to meet certain framework-wide conventions.
      Parameters:
      stageStyle - the style
      modality - the modality
      Returns:
      the stage
    • createStage

      public static javafx.stage.Stage createStage(javafx.stage.Modality modality)
      Creates a new decorated stage.
      Tentackle applications should use this factory method instead of new Stage() because the stage will be configured to meet certain framework-wide conventions.
      Parameters:
      modality - the modality
      Returns:
      the stage
    • createScene

      public static javafx.scene.Scene createScene(javafx.scene.Parent root)
      Creates a scene.
      Parameters:
      root - the parent node
      Returns:
      the scene
    • create

      public static <T, R extends T> R create(Class<T> clazz)
      Creates an object.
      FX objects should not be created via the builder factory and not the traditional way by invoking a constructor. Only the builder factory guarantees TT-compliant instances.

      Throws FxRuntimeException if no builder for this type and/or the type does not provide a no-arg constructor.

      Type Parameters:
      T - the requested FX standard type
      R - the expected type of the returned object
      Parameters:
      clazz - the object's class
      Returns:
      the created object
    • info

      public static void info(Object owner, String message, Runnable onClose)
      Shows an info dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      onClose - optional runnable invoked when dialog is closed
      See Also:
    • info

      public static void info(Object owner, String message)
      Shows an info dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      See Also:
    • warning

      public static void warning(Object owner, String message, Runnable onClose)
      Shows a warning dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      onClose - optional runnable invoked when dialog is closed
      See Also:
    • warning

      public static void warning(Object owner, String message)
      Shows a warning dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      See Also:
    • error

      public static void error(Object owner, String message, Throwable t, Runnable onClose)
      Shows an error dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      t - optional throwable
      onClose - optional runnable invoked when dialog is closed
      See Also:
    • error

      public static void error(Object owner, String message, Throwable t)
      Shows an error dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      t - optional throwable
      See Also:
    • error

      public static void error(Object owner, String message)
      Shows an error dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      See Also:
    • question

      public static void question(Object owner, String message, boolean defaultYes, Consumer<Boolean> answer)
      Shows a question dialog.
      Parameters:
      owner - the owner window or node
      message - the message
      defaultYes - true if yes is the default button
      answer - the user's answer (invoked with Boolean.TRUE or Boolean.FALSE, never null)
      See Also:
    • yes

      public static void yes(Object owner, String message, boolean defaultYes, Runnable yes)
      Shows a question dialog.
      Short for question(Object, String, boolean, Consumer) if answer is only checked for yes.
      Parameters:
      owner - the owner window or node
      message - the message
      defaultYes - true if yes is the default button
      yes - invoked if user answers with yes
      See Also:
    • no

      public static void no(Object owner, String message, boolean defaultYes, Runnable no)
      Shows a question dialog.
      Short for question(Object, String, boolean, Consumer) if answer is only checked for no.
      Parameters:
      owner - the owner window or node
      message - the message
      defaultYes - true if yes is the default button
      no - invoked if user answers with no
      See Also:
    • createGraphic

      public static javafx.scene.Node createGraphic(String realm, String name)
      Creates the graphic node for a given realm and name.
      Throws IllegalArgumentException if no such icon and/or realm.
      Parameters:
      realm - the realm, null of empty if default tentackle realm
      name - the graphic name
      Returns:
      the graphic node
    • createGraphic

      public static javafx.scene.Node createGraphic(String name)
      Creates the graphic node for a given name and the default realm.
      Throws IllegalArgumentException if no such icon.
      Parameters:
      name - the graphic name
      Returns:
      the graphic node
    • getStage

      public static javafx.stage.Stage getStage(javafx.scene.Node node)
      Gets the stage for a node.
      Parameters:
      node - the node
      Returns:
      the stage, null if node does not belong to a scene or scene does not belong to a stage.
    • isModal

      public static boolean isModal(javafx.stage.Stage stage)
      Returns whether the stage is modal.
      Parameters:
      stage - the stage
      Returns:
      true if effectively modal
    • terminate

      public static void terminate()
      Terminates the FX client.