Package jltk.gui

Class TextComponent

  • Direct Known Subclasses:
    PasswordField, TextArea, TextField

    public abstract class TextComponent
    extends Control
    A abstract class for all text components events: confirmed, selectionChanged, contentChanged
    Version:
    20.05.2022
    Author:
    ms
    • Field Detail

      • fxTextInputControl

        protected javafx.scene.control.TextInputControl fxTextInputControl
      • color

        protected javafx.scene.paint.Color color
      • onContentChanged

        protected String onContentChanged
      • onSelectionChanged

        protected String onSelectionChanged
      • onConfirmed

        protected String onConfirmed
      • newLine

        protected String newLine
      • font

        protected javafx.scene.text.Font font
    • Constructor Detail

      • TextComponent

        public TextComponent()
    • Method Detail

      • init

        protected void init​(double pLeft,
                            double pTop,
                            double pWidth,
                            double pHeight,
                            Window pWindow,
                            javafx.scene.control.TextInputControl pComponent)
      • setContent

        public void setContent​(String pText)
        The text component gets a new text as content
        Parameters:
        pText - The new text for the text component.
      • setContent

        public void setContent​(char pChar)
        The text component gets a new char as content
        Parameters:
        pText - The new char for the text component.
      • setContent

        public void setContent​(int pNumber)
        The text component gets a new integer as content
        Parameters:
        pText - The new integer for the text component.
      • setContent

        public void setContent​(long pNumber)
        The text component gets a new long integer as content
        Parameters:
        pText - The new long integer for the text component.
      • setContent

        public void setContent​(double pNumber)
        The text component gets a new decimal number (double) as content
        Parameters:
        pText - The new decimal number for the text component.
      • setContent

        public void setContent​(float pNumber)
        The text component gets a new decimal number (float) as content
        Parameters:
        pText - The new decimal number for the text component.
      • setContent

        public void setContent​(Object pObject)
        The text component gets the text representation of the given object (pObject.toString()) as content
      • append

        public void append​(String pText)
        The text will be append to the end of the text component.
        Parameters:
        pText - The text, that will be append.
      • append

        public void append​(char pChar)
        The character (char) will be append to the end of the text component.
        Parameters:
        pText - The character (char), that will be append.
      • append

        public void append​(int pNumber)
        The integer will be append to the end of the text component.
        Parameters:
        pText - The integer, that will be append.
      • append

        public void append​(long pNumber)
        The long integer will be append to the end of the text component.
        Parameters:
        pText - The long integer, that will be append.
      • append

        public void append​(double pNumber)
        The decimal number (double) will be append to the end of the text component.
        Parameters:
        pText - The double, that will be append.
      • append

        public void append​(float pNumber)
        The float number will be append to the end of the text component.
        Parameters:
        pText - The float number, that will be append.
      • append

        public void append​(Object pObject)
        The float number will be append to the end of the text component.
        Parameters:
        pText - The float number, that will be append.
      • contentIsInteger

        public boolean contentIsInteger()
        Check, if content of this text component is an integer.
        Returns:
        true, if the content is an integer
      • contentIsLongInteger

        public boolean contentIsLongInteger()
        Check, if content of this text component is an long integer.
        Returns:
        true, if the content is an long integer
      • contentIsDouble

        public boolean contentIsDouble()
        Check, if content of this text component is an double.
        Returns:
        true, if the content is an double
      • contentIsFloat

        public boolean contentIsFloat()
        Check, if content of this text component is an float.
        Returns:
        true, if the content is an float
      • clear

        public void clear()
        Removes the current content of the text component.
      • getSelectedText

        public String getSelectedText()
        Returns the selected text in this text component
        Returns:
        the selected text
      • selectAll

        public void selectAll()
        Selects the whole text
      • getLength

        public int getLength()
        Returns the number of characters in this text component.
      • getSelectionStart

        public int getSelectionStart()
        Returns the index of the character, the selction starts.
      • getSelectionEnd

        public int getSelectionEnd()
        Returns the index of the character, the selction ends.
      • enableEdit

        public void enableEdit()
        Make the text component editable
      • disableEdit

        public void disableEdit()
        Make the text component read-only
      • isEditable

        public boolean isEditable()
        Returns true if the textcomponent is editable, else false.
      • getContentAsString

        public String getContentAsString()
        Returns the content of the text component as string.
        Returns:
        The content of the textcomponent as string
      • getContentAsInteger

        public int getContentAsInteger()
                                throws ArithmeticException
        Returns the content of the text component as integer.
        Returns:
        The content of the textcomponent as integer
        Throws:
        ArithmeticException
      • getContentAsLongInteger

        public long getContentAsLongInteger()
                                     throws ArithmeticException
        Returns the content of the text component as long integer.
        Returns:
        The content of the textcomponent as long
        Throws:
        ArithmeticException
      • getContentAsDouble

        public double getContentAsDouble()
                                  throws ArithmeticException
        Returns the content of the text component as double.
        Returns:
        The content of the textcomponent as double
        Throws:
        ArithmeticException
      • getContentAsFloat

        public float getContentAsFloat()
                                throws ArithmeticException
        Returns the content of the text component as float.
        Returns:
        The content of the textcomponent as float
        Throws:
        ArithmeticException
      • setFontColor

        public void setFontColor​(javafx.scene.paint.Color pColor)
      • setFontColor

        public void setFontColor​(String pColor)
      • setFontColor

        public void setFontColor​(double pRed,
                                 double pGreen,
                                 double pBlue)
        The font color of the text 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)
      • setFont

        public void setFont​(String pFontName)
        Sets the font family, as parameter you can use e.g. Verdana, Helvetica, Times New Roman, Comic Sans MS, Impact, Lucida Sans Unicode. You can print all available fonts of your system, if you run jltk.util.Misc.printAvailableFontNames().
        Parameters:
        pFont - The font family
      • setFontSize

        public void setFontSize​(double pSize)
        Sets the size of the text
        Parameters:
        pSize - The font size
      • getFontSize

        public double getFontSize()
        Returns the currently used font size.
        Returns:
        The font size.
      • setFontStyle

        public void setFontStyle​(boolean pBold,
                                 boolean pItalic)
        Set the font style of this text component.
        Parameters:
        pBold - true if bold, else false
        pItalic - true if italic, else false
      • setOnConfirmed

        public void setOnConfirmed​(String pMethodName)
        Set the name of the method which will be invoked, if the content of the text component changed .
      • setOnContentChanged

        public void setOnContentChanged​(String pMethodName)
        Set the name of the method, which will be invoked, it the user confirms change (Enter pressed).
      • setOnSelectionChanged

        public void setOnSelectionChanged​(String pMethodName)
        Set the name of the method, which will be invoked, it the user confirms change (Enter pressed).