Package jltk.gui
Class Control
- java.lang.Object
-
- jltk.Component
-
- jltk.gui.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 Summary
Fields Modifier and Type Field Description protected javafx.scene.paint.Color
color
protected javafx.scene.control.Control
fxControl
-
Fields inherited from class jltk.Component
fxNode, hasFocus, myWindow, onFocusGained, onFocusLost
-
-
Constructor Summary
Constructors Constructor Description Control()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.scene.paint.Color
getColor()
Return the color of the component.double
getHeight()
Return the height of the componentdouble
getWidth()
Return the width of the componentprotected 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.void
setColor(double pRed, double pGreen, double pBlue)
The background color of the component will be changed to specified rgb-colorvoid
setColor(String pColor)
The background color of the component will be changed.void
setColor(javafx.scene.paint.Color pColor)
The backgroundcolor of the component will be changed.void
setHeight(double pHeight)
Set the new height of this component to the specified value.void
setSize(double pWidth, double pHeight)
Sets the new size of the component.void
setTooltip(String pText)
This component get an tooltip.void
setWidth(double pWidth)
Set the new width of this component to the specified value.-
Methods inherited from class jltk.Component
activate, deactivate, focus, getX, getY, hasFocus, hide, init, istActive, isVisible, runMethodByName, setOnFocusGained, setOnFocusLost, setPosition, show, toBack, toFront
-
-
-
-
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 coordinatepY
- The vertical coordinatepWidth
- The width of the componentpHeight
- The height of the componentpWindow
- The window on which the component should be placedpComponent
- 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 widthpHeight
- 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
-
getColor
public javafx.scene.paint.Color getColor()
Return the color of the component.- Returns:
- The color of the component
- See Also:
setColor(String)
,setColor(Color)
,setColor(double,double,double)
-
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
-
-