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.Color
color
protected javafx.scene.text.Font
font
protected javafx.scene.control.TextInputControl
fxTextInputControl
protected String
newLine
protected String
onConfirmed
protected String
onContentChanged
protected String
onSelectionChanged
-
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 void
append(char pChar)
The character (char) will be append to the end of the text component.void
append(double pNumber)
The decimal number (double) will be append to the end of the text component.void
append(float pNumber)
The float number will be append to the end of the text component.void
append(int pNumber)
The integer will be append to the end of the text component.void
append(long pNumber)
The long integer will be append to the end of the text component.void
append(Object pObject)
The float number will be append to the end of the text component.void
append(String pText)
The text will be append to the end of the text component.void
clear()
Removes the current content of the text component.boolean
contentIsDouble()
Check, if content of this text component is an double.boolean
contentIsFloat()
Check, if content of this text component is an float.boolean
contentIsInteger()
Check, if content of this text component is an integer.boolean
contentIsLongInteger()
Check, if content of this text component is an long integer.void
disableEdit()
Make the text component read-onlyvoid
enableEdit()
Make the text component editabledouble
getContentAsDouble()
Returns the content of the text component as double.float
getContentAsFloat()
Returns the content of the text component as float.int
getContentAsInteger()
Returns the content of the text component as integer.long
getContentAsLongInteger()
Returns the content of the text component as long integer.String
getContentAsString()
Returns the content of the text component as string.String
getFont()
Returns the name of the font family (also see. setFont()).double
getFontSize()
Returns the currently used font size.int
getLength()
Returns the number of characters in this text component.String
getSelectedText()
Returns the selected text in this text componentint
getSelectionEnd()
Returns the index of the character, the selction ends.int
getSelectionStart()
Returns the index of the character, the selction starts.protected void
init(double pLeft, double pTop, double pWidth, double pHeight, Window pWindow, javafx.scene.control.TextInputControl pComponent)
boolean
isEditable()
Returns true if the textcomponent is editable, else false.void
selectAll()
Selects the whole textvoid
setContent(char pChar)
The text component gets a new char as contentvoid
setContent(double pNumber)
The text component gets a new decimal number (double) as contentvoid
setContent(float pNumber)
The text component gets a new decimal number (float) as contentvoid
setContent(int pNumber)
The text component gets a new integer as contentvoid
setContent(long pNumber)
The text component gets a new long integer as contentvoid
setContent(Object pObject)
The text component gets the text representation of the given object (pObject.toString()) as contentvoid
setContent(String pText)
The text component gets a new text as contentvoid
setFont(String pFontName)
Sets the font family, as parameter you can use e.g.void
setFontColor(double pRed, double pGreen, double pBlue)
The font color of the text component will be changed to specified rgb-colorvoid
setFontColor(String pColor)
void
setFontColor(javafx.scene.paint.Color pColor)
void
setFontSize(double pSize)
Sets the size of the textvoid
setFontStyle(boolean pBold, boolean pItalic)
Set the font style of this text component.void
setOnConfirmed(String pMethodName)
Set the name of the method which will be invoked, if the content of the text component changed .void
setOnContentChanged(String pMethodName)
Set the name of the method, which will be invoked, it the user confirms change (Enter pressed).void
setOnSelectionChanged(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 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
-
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).
-
-