Package jltk.gui
Class TextComponent
- java.lang.Object
-
- jltk.Component
-
- jltk.gui.Control
-
- jltk.gui.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 Summary
Fields Modifier and Type Field Description protected javafx.scene.paint.Colorcolorprotected javafx.scene.text.Fontfontprotected javafx.scene.control.TextInputControlfxTextInputControlprotected StringnewLineprotected StringonConfirmedprotected StringonContentChangedprotected StringonSelectionChanged-
Fields inherited from class jltk.Component
fxNode, hasFocus, myWindow, onFocusGained, onFocusLost
-
-
Constructor Summary
Constructors Constructor Description TextComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char pChar)The character (char) will be append to the end of the text component.voidappend(double pNumber)The decimal number (double) will be append to the end of the text component.voidappend(float pNumber)The float number will be append to the end of the text component.voidappend(int pNumber)The integer will be append to the end of the text component.voidappend(long pNumber)The long integer will be append to the end of the text component.voidappend(Object pObject)The float number will be append to the end of the text component.voidappend(String pText)The text will be append to the end of the text component.voidclear()Removes the current content of the text component.booleancontentIsDouble()Check, if content of this text component is an double.booleancontentIsFloat()Check, if content of this text component is an float.booleancontentIsInteger()Check, if content of this text component is an integer.booleancontentIsLongInteger()Check, if content of this text component is an long integer.voiddisableEdit()Make the text component read-onlyvoidenableEdit()Make the text component editabledoublegetContentAsDouble()Returns the content of the text component as double.floatgetContentAsFloat()Returns the content of the text component as float.intgetContentAsInteger()Returns the content of the text component as integer.longgetContentAsLongInteger()Returns the content of the text component as long integer.StringgetContentAsString()Returns the content of the text component as string.StringgetFont()Returns the name of the font family (also see. setFont()).doublegetFontSize()Returns the currently used font size.intgetLength()Returns the number of characters in this text component.StringgetSelectedText()Returns the selected text in this text componentintgetSelectionEnd()Returns the index of the character, the selction ends.intgetSelectionStart()Returns the index of the character, the selction starts.protected voidinit(double pLeft, double pTop, double pWidth, double pHeight, Window pWindow, javafx.scene.control.TextInputControl pComponent)booleanisEditable()Returns true if the textcomponent is editable, else false.voidselectAll()Selects the whole textvoidsetContent(char pChar)The text component gets a new char as contentvoidsetContent(double pNumber)The text component gets a new decimal number (double) as contentvoidsetContent(float pNumber)The text component gets a new decimal number (float) as contentvoidsetContent(int pNumber)The text component gets a new integer as contentvoidsetContent(long pNumber)The text component gets a new long integer as contentvoidsetContent(Object pObject)The text component gets the text representation of the given object (pObject.toString()) as contentvoidsetContent(String pText)The text component gets a new text as contentvoidsetFont(String pFontName)Sets the font family, as parameter you can use e.g.voidsetFontColor(double pRed, double pGreen, double pBlue)The font color of the text component will be changed to specified rgb-colorvoidsetFontColor(String pColor)voidsetFontColor(javafx.scene.paint.Color pColor)voidsetFontSize(double pSize)Sets the size of the textvoidsetFontStyle(boolean pBold, boolean pItalic)Set the font style of this text component.voidsetOnConfirmed(String pMethodName)Set the name of the method which will be invoked, if the content of the text component changed .voidsetOnContentChanged(String pMethodName)Set the name of the method, which will be invoked, it the user confirms change (Enter pressed).voidsetOnSelectionChanged(String pMethodName)Set the name of the method, which will be invoked, it the user confirms change (Enter pressed).-
Methods inherited from class jltk.gui.Control
getColor, getHeight, getWidth, init, setColor, setColor, setColor, setHeight, setSize, setTooltip, setWidth
-
Methods inherited from class jltk.Component
activate, deactivate, focus, getX, getY, hasFocus, hide, init, istActive, isVisible, runMethodByName, setOnFocusGained, setOnFocusLost, setPosition, show, toBack, toFront
-
-
-
-
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
-
-
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 ArithmeticExceptionReturns the content of the text component as integer.- Returns:
- The content of the textcomponent as integer
- Throws:
ArithmeticException
-
getContentAsLongInteger
public long getContentAsLongInteger() throws ArithmeticExceptionReturns the content of the text component as long integer.- Returns:
- The content of the textcomponent as long
- Throws:
ArithmeticException
-
getContentAsDouble
public double getContentAsDouble() throws ArithmeticExceptionReturns the content of the text component as double.- Returns:
- The content of the textcomponent as double
- Throws:
ArithmeticException
-
getContentAsFloat
public float getContentAsFloat() throws ArithmeticExceptionReturns 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
-
getFont
public String getFont()
Returns the name of the font family (also see. setFont()).- Returns:
- The font family
- See Also:
setFont(String),Misc.printAvailableFontNames()
-
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 falsepItalic- 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).
-
-