Class Fx


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javafx.scene.image.ImageView createImageView​(java.lang.String name)
      Creates an image view for a tentackle image.
      static javafx.scene.image.ImageView createImageView​(java.lang.String realm, java.lang.String name)
      Creates an image view for an image.
      static <T,​R extends T>
      R
      createNode​(java.lang.Class<T> clazz)
      Creates a node.
      Nodes should not be created via the builder factory and not the tradional way by invoking a constructor.
      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 javafx.scene.control.Alert error​(java.lang.String message)
      Shows an error dialog.
      static javafx.scene.control.Alert error​(java.lang.String message, java.lang.Throwable t)
      Shows an error dialog.
      static javafx.scene.control.Alert error​(java.lang.String message, java.lang.Throwable t, java.lang.String title)
      Shows an error dialog.
      static javafx.stage.Stage getStage​(javafx.scene.Node node)
      Gets the stage for a node.
      static javafx.scene.control.Alert info​(java.lang.String message)
      Shows an info dialog.
      static javafx.scene.control.Alert info​(java.lang.String message, java.lang.String title)
      Shows an info dialog.
      static boolean isModal​(javafx.stage.Stage stage)
      Returns whether the stage is modal.
      static <T extends FxController>
      T
      load​(java.lang.Class<T> controllerClass)
      Loads a controller with its FXML-view.
      static <T> T load​(java.net.URL location)
      Loads an object hierarchy from a FXML document.
      static <T> T load​(java.net.URL location, java.util.ResourceBundle resources)
      Loads an object hierarchy from a FXML document.
      static javafx.scene.control.Alert no​(java.lang.String message, boolean defaultYes, java.lang.Runnable no)
      Shows a question dialog.
      Short for question(String, boolean, Consumer) if answer is only checked for no.
      static javafx.scene.control.Alert question​(java.lang.String message, boolean defaultYes, java.lang.String title, java.util.function.Consumer<java.lang.Boolean> answer)
      Shows a question dialog.
      static javafx.scene.control.Alert question​(java.lang.String message, boolean defaultYes, java.util.function.Consumer<java.lang.Boolean> answer)
      Shows a question dialog.
      static javafx.scene.control.Alert warning​(java.lang.String message)
      Shows a warning dialog.
      static javafx.scene.control.Alert warning​(java.lang.String message, java.lang.String title)
      Shows a warning dialog.
      static javafx.scene.control.Alert yes​(java.lang.String message, boolean defaultYes, java.lang.Runnable yes)
      Shows a question dialog.
      Short for question(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 Detail

      • load

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

        public static <T> T load​(java.net.URL location,
                                 java.util.ResourceBundle resources)
                          throws java.io.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:
        java.io.IOException - if loading failed
      • load

        public static <T extends FxController> T load​(java.lang.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
      • createNode

        public static <T,​R extends T> R createNode​(java.lang.Class<T> clazz)
        Creates a node.
        Nodes should not be created via the builder factory and not the tradional way by invoking a constructor. Only the builder factory guarantees TT-compliant instances.
        Type Parameters:
        T - the requested FX standard node type
        R - the expected type of the returned node
        Parameters:
        clazz - the node's class
        Returns:
        the node instance
      • info

        public static javafx.scene.control.Alert info​(java.lang.String message,
                                                      java.lang.String title)
        Shows an info dialog.
        Parameters:
        message - the message
        title - optional title
        Returns:
        the alert dialog
      • info

        public static javafx.scene.control.Alert info​(java.lang.String message)
        Shows an info dialog.
        Parameters:
        message - the message
        Returns:
        the alert dialog
      • warning

        public static javafx.scene.control.Alert warning​(java.lang.String message,
                                                         java.lang.String title)
        Shows a warning dialog.
        Parameters:
        message - the message
        title - optional title
        Returns:
        the alert dialog
      • warning

        public static javafx.scene.control.Alert warning​(java.lang.String message)
        Shows a warning dialog.
        Parameters:
        message - the message
        Returns:
        the alert dialog
      • question

        public static javafx.scene.control.Alert question​(java.lang.String message,
                                                          boolean defaultYes,
                                                          java.lang.String title,
                                                          java.util.function.Consumer<java.lang.Boolean> answer)
        Shows a question dialog.
        Parameters:
        message - the message
        defaultYes - true if yes is the default button
        title - optional title
        answer - the user's answer (invoked with Boolean.TRUE or Boolean.FALSE, never null)
        Returns:
        the alert dialog
      • question

        public static javafx.scene.control.Alert question​(java.lang.String message,
                                                          boolean defaultYes,
                                                          java.util.function.Consumer<java.lang.Boolean> answer)
        Shows a question dialog.
        Parameters:
        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)
        Returns:
        the alert dialog
      • yes

        public static javafx.scene.control.Alert yes​(java.lang.String message,
                                                     boolean defaultYes,
                                                     java.lang.Runnable yes)
        Shows a question dialog.
        Short for question(String, boolean, Consumer) if answer is only checked for yes.
        Parameters:
        message - the message
        defaultYes - true if yes is the default button
        yes - invoked if user answers with yes
        Returns:
        the alert dialog
      • no

        public static javafx.scene.control.Alert no​(java.lang.String message,
                                                    boolean defaultYes,
                                                    java.lang.Runnable no)
        Shows a question dialog.
        Short for question(String, boolean, Consumer) if answer is only checked for no.
        Parameters:
        message - the message
        defaultYes - true if yes is the default button
        no - invoked if user answers with no
        Returns:
        the alert dialog
      • error

        public static javafx.scene.control.Alert error​(java.lang.String message,
                                                       java.lang.Throwable t,
                                                       java.lang.String title)
        Shows an error dialog.
        Parameters:
        message - the message
        t - optional throwable
        title - optional title
        Returns:
        the alert dialog
      • error

        public static javafx.scene.control.Alert error​(java.lang.String message,
                                                       java.lang.Throwable t)
        Shows an error dialog.
        Parameters:
        message - the message
        t - optional throwable
        Returns:
        the alert dialog
      • error

        public static javafx.scene.control.Alert error​(java.lang.String message)
        Shows an error dialog.
        Parameters:
        message - the message
        Returns:
        the alert dialog
      • createImageView

        public static javafx.scene.image.ImageView createImageView​(java.lang.String realm,
                                                                   java.lang.String name)
        Creates an image view for an image.
        Parameters:
        realm - the realm, null or empty if tentackle images
        name - the image's name
        Returns:
        the view
      • createImageView

        public static javafx.scene.image.ImageView createImageView​(java.lang.String name)
        Creates an image view for a tentackle image.
        Parameters:
        name - the image's name
        Returns:
        the view
      • 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