Package jltk

Class Component

  • Direct Known Subclasses:
    Control, Shape, Video

    public abstract class Component
    extends Object
    abstract class Component - The base class for all elements that can be put on a window (e.g. shapes an gui elements). Each component can invoke a method, when it gets or losts focus. It is also possible to make it visible or hide it Each element has an absolute position on the window. For gui elements the position is defined by the upper-left corner of the element. For shapes the postion depends on the form of the shape. Please see the corresponding documentation of the shape.
    Version:
    25.3.2022
    Author:
    ms
    • Constructor Summary

      Constructors 
      Constructor Description
      Component()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activate()
      Activate the component.
      void deactivate()
      Deactivate the component (grey out).
      void focus()
      The component gets the input focus.
      double getX()
      Return the x-coordinate of the top left corner of this component
      double getY()
      Returns the y-coordinate of the top left corner of this component
      boolean hasFocus()
      Returns wether the component has focus or not.
      void hide()
      The component is not visible any more
      protected void init​(javafx.scene.Node pNode)
      Basic initialisation for every component which could be placed on a window.
      boolean istActive()
      Returns wether the component is active or not.
      boolean isVisible()
      Return true, if the component is visible
      protected void runMethodByName​(String pMethodname)
      Runs the method pMethodenname.
      void setOnFocusGained​(String pMethod)
      Set the name of the method, which will be invoked,if this component gets the focus.
      void setOnFocusLost​(String pMethod)
      Set the name of the method, which will be invoked, if this component lost the focus.
      void setPosition​(double pX, double pY)
      The component gets a new position (top left corner)
      void show()
      The component will be hiden.
      void toBack()  
      void toFront()  
    • Field Detail

      • fxNode

        public javafx.scene.Node fxNode
      • onFocusLost

        protected String onFocusLost
      • onFocusGained

        protected String onFocusGained
      • hasFocus

        protected boolean hasFocus
      • myWindow

        protected Window myWindow
    • Constructor Detail

      • Component

        public Component()
    • Method Detail

      • init

        protected void init​(javafx.scene.Node pNode)
        Basic initialisation for every component which could be placed on a window.
        Parameters:
        pNode - The Node should be placed on this window.
      • setOnFocusGained

        public void setOnFocusGained​(String pMethod)
        Set the name of the method, which will be invoked,if this component gets the focus.
      • setOnFocusLost

        public void setOnFocusLost​(String pMethod)
        Set the name of the method, which will be invoked, if this component lost the focus.
      • runMethodByName

        protected void runMethodByName​(String pMethodname)
        Runs the method pMethodenname. The method must be located in a subclass of the class App. In the class App is an static attribut theApp which points to last initialized instance of App. Because of this, there should be only one instance of class App.
        Parameters:
        pMethodname - The name of the method (must be located in a subclass of App)
      • toFront

        public void toFront()
      • toBack

        public void toBack()
      • hide

        public void hide()
        The component is not visible any more
      • show

        public void show()
        The component will be hiden.
      • isVisible

        public boolean isVisible()
        Return true, if the component is visible
      • focus

        public void focus()
        The component gets the input focus.
      • hasFocus

        public boolean hasFocus()
        Returns wether the component has focus or not.
        Returns:
        true, if this component has the focus
      • deactivate

        public void deactivate()
        Deactivate the component (grey out).
      • activate

        public void activate()
        Activate the component.
      • istActive

        public boolean istActive()
        Returns wether the component is active or not.
        Returns:
        true, if the component ist active
      • getX

        public double getX()
        Return the x-coordinate of the top left corner of this component
        Returns:
        The x-coordinate of this component.
        See Also:
        #setX(double)
      • getY

        public double getY()
        Returns the y-coordinate of the top left corner of this component
        Returns:
        the y-coordinate of this component
        See Also:
        #setY(double)
      • setPosition

        public void setPosition​(double pX,
                                double pY)
        The component gets a new position (top left corner)
        Parameters:
        pX - new horizontal position of the top left corner.
        pY - new vertical position of the top left corner.