Package jltk

Class Window


  • public class Window
    extends Object
    A object of this class represents a window of an graphical user interface (gui). On this window you can draw with a pen or you can place gui elements like button, textfields, et cetera. (See class App for more information how to use gui elements).
    For this purpose the window use a coordination system. The origin of the coordinate system is the upper left corner of the window. The x-axis points to the right, the y-axis points down.
    Version:
    08.04.2022
    Author:
    ms
    • Constructor Summary

      Constructors 
      Constructor Description
      Window()
      Creates a window that fills the entire screen
      Window​(int pWidth, int pHeight)
      Creates a window with the specified size.
      Window​(int pLeft, int pTop, int pWidth, int pHeight)
      Creates a window with the specified size and the specified position.
      Window​(int pLeft, int pTop, int pWidth, int pHeight, String pName)
      Creates a window with the specified size, the specified position and the specified title.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addComponent​(javafx.scene.Node pComponent)
      Add a component to the window.
      void alwaysOnTop​(boolean pOnTop)
      Specify if this window is always on top of every other window.
      void clear()
      Removes all drawings made by a pen from this window.
      void delay​(long pMilliseconds)
      Delays the execution by the specified amount of milliseconds.
      protected javafx.scene.canvas.GraphicsContext g()
      The GraphicsOCntext of the canvas.
      javafx.scene.paint.Color getColor()
      Return the current Backgroundcolor of this window
      int getHeight()
      Return the height of this window.
      protected double getMouseX()
      Return the current x-coordinate of the mouse.
      protected double getMouseY()
      Return the current y-coordinate of the mouse.
      int getWidth()
      Return the width of this window.
      protected void gridToFront()
      Put the grid in the foreground.
      boolean hasFocus()
      Return true, if this windows currently has the focus.
      void hideGrid()
      Hides the grid.
      protected void setAppInstance​(App pInstance)
      Set the attribute appInstance to an instance of a subclass of App, which use this screen.
      void setColor​(double pRed, double pGreen, double pBlue)
      The background color of the window will be changed to specified rgb-color
      void setColor​(String pColor)
      The background color of the window will be changed.
      void setColor​(javafx.scene.paint.Color pColor)
      The background color of the window will be changed to specified color
      void setTitle​(String pTitle)
      Set the title of this window to the specified name.
      void showGrid()
      Showing a grid for this windows.
      void toFront()
      Moves this window to the front of all other windows.
    • Field Detail

      • firstWindow

        public static Window firstWindow
      • topWindow

        public static Window topWindow
      • appInstance

        protected App appInstance
      • windowID

        protected static int windowID
      • defaultFrameTitle

        protected static String defaultFrameTitle
      • mouseX

        protected double mouseX
      • mouseY

        protected double mouseY
      • isMouseButtonDown

        protected boolean isMouseButtonDown
      • buttonNumber

        protected int buttonNumber
      • wasDoubleClick

        protected boolean wasDoubleClick
      • hasFocus

        protected boolean hasFocus
      • gridXTicks

        public int gridXTicks
      • gridYTicks

        public int gridYTicks
    • Constructor Detail

      • Window

        public Window()
        Creates a window that fills the entire screen
      • Window

        public Window​(int pLeft,
                      int pTop,
                      int pWidth,
                      int pHeight)
        Creates a window with the specified size and the specified position.
        Parameters:
        pLeft - The x-coordinate of the upper left corner
        pTop - The y-coordinate of the upper left corner
        pWidth - The width of the window
        pHeight - The height of the window
      • Window

        public Window​(int pWidth,
                      int pHeight)
        Creates a window with the specified size.
        Parameters:
        pWidth - The width of the window
        pHeight - The height of the window
      • Window

        public Window​(int pLeft,
                      int pTop,
                      int pWidth,
                      int pHeight,
                      String pName)
        Creates a window with the specified size, the specified position and the specified title.
        Parameters:
        pLeft - The x-coordinate of the upper left corner
        pTop - The y-coordinate of the upper left corner
        pWidth - The width of the window
        pHeight - The height of the window
        pTitle - The window title
    • Method Detail

      • delay

        public void delay​(long pMilliseconds)
        Delays the execution by the specified amount of milliseconds.
        Parameters:
        pMilliseconds - The duration of delay in milliseconds
      • addComponent

        public void addComponent​(javafx.scene.Node pComponent)
        Add a component to the window. This method is mostlx for internal use but you can also add any javafx.scene.Node object to the windows, too.
        Parameters:
        pComponent - The object, which should place on the window.
      • getHeight

        public int getHeight()
        Return the height of this window.
        Returns:
        The height of this window
      • getWidth

        public int getWidth()
        Return the width of this window.
        Returns:
        The width of this window
      • getMouseX

        protected double getMouseX()
        Return the current x-coordinate of the mouse.
        Returns:
        The x-coordinate of the mouse
      • getMouseY

        protected double getMouseY()
        Return the current y-coordinate of the mouse.
        Returns:
        The y-coordinate of the mouse
      • setColor

        public void setColor​(javafx.scene.paint.Color pColor)
        The background color of the window will be changed to specified color
        Parameters:
        pColor - The new background color
      • setColor

        public void setColor​(double pRed,
                             double pGreen,
                             double pBlue)
        The background color of the window will be changed to specified rgb-color
        Parameters:
        pRed - the red proportion (must be between 0 and 1)
        pGreen - the green proportion (must be between 0 and 1)
        pBlue - the blue proportion (must be between 0 and 1)
      • setColor

        public void setColor​(String pColor)
        The background color of the window will be changed. As parameter you can use the color name from the javafx.scene.paint.Color field https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html#field.summary For example setColor("ALICEBLUE") or setColor("blue").
        Parameters:
        pColor - the new background color color
      • getColor

        public javafx.scene.paint.Color getColor()
        Return the current Backgroundcolor of this window
        Returns:
        The background color
      • hasFocus

        public boolean hasFocus()
        Return true, if this windows currently has the focus.
        Returns:
        Der R├╝ckgabewert
      • alwaysOnTop

        public void alwaysOnTop​(boolean pOnTop)
        Specify if this window is always on top of every other window.
        Parameters:
        true - : always on top is activate, false: always on top is deactivate
      • toFront

        public void toFront()
        Moves this window to the front of all other windows.
      • clear

        public void clear()
        Removes all drawings made by a pen from this window.
      • g

        protected javafx.scene.canvas.GraphicsContext g()
        The GraphicsOCntext of the canvas. Used by the pen.
      • setAppInstance

        protected void setAppInstance​(App pInstance)
        Set the attribute appInstance to an instance of a subclass of App, which use this screen.
      • showGrid

        public void showGrid()
        Showing a grid for this windows. You can change the width between two ticks by changing the attribute gridXTicks and gridYTicks.
      • hideGrid

        public void hideGrid()
        Hides the grid.
      • gridToFront

        protected void gridToFront()
        Put the grid in the foreground.
      • setTitle

        public void setTitle​(String pTitle)
        Set the title of this window to the specified name.
        Parameters:
        pTitle - The new window title