Package jltk.gui

Class Control

  • Direct Known Subclasses:
    ComboBox, Image, Labeled, ListView, ProgressBar, ProgressIndicator, Separator, Slider, Spinner, Table, TextComponent

    public abstract class Control
    extends Component
    abstract class Control - The base class for all gui elements Each element has an absolute position, which is defined by the upper left corner.

    To use a gui component, you have to create a subclass of the class App (public class myClass extends App {...} ). Then create an object of the gui component you like and pass the position and size to the constructor:

    Button myButton = new Button(50,75,100,25,"Hello World")

    The button will be occure on the window that belongs to the App instance. In this case the upper left corner of the button has the coordinates (50,75) and the size 100x25. The button is labled with "Hello World".
    For each component different eventhandler can be set. For example:

    myButton.onButtonClicked("myMethod")
    Every time the button is clicked, the method myMethod is invoked. myMethod must be implement in your subclass of App.

    Please see the documentation of the different classes in package jltk.gui for detailed information.

    Version:
    25.3.2022
    Author:
    ms
    • Field Detail

      • fxControl

        protected javafx.scene.control.Control fxControl
      • color

        protected javafx.scene.paint.Color color
    • Constructor Detail

      • Control

        public Control()
    • Method Detail

      • init

        protected void init​(double pX,
                            double pY,
                            double pWidth,
                            double pHeight,
                            Window pWindow,
                            javafx.scene.control.Control pComponent)
        Basic initialisation, like setting postion and size, add the Element to the window. For some reason this cannot be solved using a constructor, because in subclasses the javaFX component must be initialised first. After this, init must be called.
        Parameters:
        pX - The horizontal coordinate
        pY - The vertical coordinate
        pWidth - The width of the component
        pHeight - The height of the component
        pWindow - The window on which the component should be placed
        pComponent - The corresponding JavaFX-Component
      • setWidth

        public void setWidth​(double pWidth)
        Set the new width of this component to the specified value.
        Parameters:
        pWidth - The new width of this component
      • setHeight

        public void setHeight​(double pHeight)
        Set the new height of this component to the specified value.
        Parameters:
        pHeight - The new height of this component
      • setSize

        public void setSize​(double pWidth,
                            double pHeight)
        Sets the new size of the component.
        Parameters:
        pWidth - the new width
        pHeight - the new height
      • setColor

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

        public void setColor​(double pRed,
                             double pGreen,
                             double pBlue)
        The background color of the component 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 component 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 color
      • getHeight

        public double getHeight()
        Return the height of the component
        Returns:
        The height of the component
      • getWidth

        public double getWidth()
        Return the width of the component
        Returns:
        The width of the component
      • setTooltip

        public void setTooltip​(String pText)
        This component get an tooltip. Tooltips typically shown, if the mouse moves over the component.
        Parameters:
        pText - the text of the tooltip