Package jltk
Class Window
- java.lang.Object
-
- jltk.Window
-
public class Window extends Object
A object of this class represents a window of an graphical user interface (gui). On this window you can draw with a pen or you can place gui elements like button, textfields, et cetera. (See class App for more information how to use gui elements).
For this purpose the window use a coordination system. The origin of the coordinate system is the upper left corner of the window. The x-axis points to the right, the y-axis points down.- Version:
- 08.04.2022
- Author:
- ms
-
-
Field Summary
Fields Modifier and Type Field Description protected AppappInstanceprotected intbuttonNumberprotected static StringdefaultFrameTitlestatic WindowfirstWindow(package private) ArrayList<javafx.scene.Node>gridintgridXTicksintgridYTicksprotected booleanhasFocusprotected booleanisMouseButtonDownprotected Vector<String>keyboardBufferprotected doublemouseXprotected doublemouseYstatic WindowtopWindowprotected booleanwasDoubleClickprotected static intwindowID
-
Constructor Summary
Constructors Constructor Description Window()Creates a window that fills the entire screenWindow(int pWidth, int pHeight)Creates a window with the specified size.Window(int pLeft, int pTop, int pWidth, int pHeight)Creates a window with the specified size and the specified position.Window(int pLeft, int pTop, int pWidth, int pHeight, String pName)Creates a window with the specified size, the specified position and the specified title.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComponent(javafx.scene.Node pComponent)Add a component to the window.voidalwaysOnTop(boolean pOnTop)Specify if this window is always on top of every other window.voidclear()Removes all drawings made by a pen from this window.voiddelay(long pMilliseconds)Delays the execution by the specified amount of milliseconds.protected javafx.scene.canvas.GraphicsContextg()The GraphicsOCntext of the canvas.javafx.scene.paint.ColorgetColor()Return the current Backgroundcolor of this windowintgetHeight()Return the height of this window.protected doublegetMouseX()Return the current x-coordinate of the mouse.protected doublegetMouseY()Return the current y-coordinate of the mouse.intgetWidth()Return the width of this window.protected voidgridToFront()Put the grid in the foreground.booleanhasFocus()Return true, if this windows currently has the focus.voidhideGrid()Hides the grid.protected voidsetAppInstance(App pInstance)Set the attribute appInstance to an instance of a subclass of App, which use this screen.voidsetColor(double pRed, double pGreen, double pBlue)The background color of the window will be changed to specified rgb-colorvoidsetColor(String pColor)The background color of the window will be changed.voidsetColor(javafx.scene.paint.Color pColor)The background color of the window will be changed to specified colorvoidsetTitle(String pTitle)Set the title of this window to the specified name.voidshowGrid()Showing a grid for this windows.voidtoFront()Moves this window to the front of all other windows.
-
-
-
Field Detail
-
firstWindow
public static Window firstWindow
-
topWindow
public static Window topWindow
-
appInstance
protected App appInstance
-
windowID
protected static int windowID
-
defaultFrameTitle
protected static String defaultFrameTitle
-
mouseX
protected double mouseX
-
mouseY
protected double mouseY
-
isMouseButtonDown
protected boolean isMouseButtonDown
-
buttonNumber
protected int buttonNumber
-
wasDoubleClick
protected boolean wasDoubleClick
-
hasFocus
protected boolean hasFocus
-
gridXTicks
public int gridXTicks
-
gridYTicks
public int gridYTicks
-
grid
ArrayList<javafx.scene.Node> grid
-
-
Constructor Detail
-
Window
public Window()
Creates a window that fills the entire screen
-
Window
public Window(int pLeft, int pTop, int pWidth, int pHeight)Creates a window with the specified size and the specified position.- Parameters:
pLeft- The x-coordinate of the upper left cornerpTop- The y-coordinate of the upper left cornerpWidth- The width of the windowpHeight- The height of the window
-
Window
public Window(int pWidth, int pHeight)Creates a window with the specified size.- Parameters:
pWidth- The width of the windowpHeight- The height of the window
-
Window
public Window(int pLeft, int pTop, int pWidth, int pHeight, String pName)Creates a window with the specified size, the specified position and the specified title.- Parameters:
pLeft- The x-coordinate of the upper left cornerpTop- The y-coordinate of the upper left cornerpWidth- The width of the windowpHeight- The height of the windowpTitle- The window title
-
-
Method Detail
-
delay
public void delay(long pMilliseconds)
Delays the execution by the specified amount of milliseconds.- Parameters:
pMilliseconds- The duration of delay in milliseconds
-
addComponent
public void addComponent(javafx.scene.Node pComponent)
Add a component to the window. This method is mostlx for internal use but you can also add any javafx.scene.Node object to the windows, too.- Parameters:
pComponent- The object, which should place on the window.
-
getHeight
public int getHeight()
Return the height of this window.- Returns:
- The height of this window
-
getWidth
public int getWidth()
Return the width of this window.- Returns:
- The width of this window
-
getMouseX
protected double getMouseX()
Return the current x-coordinate of the mouse.- Returns:
- The x-coordinate of the mouse
-
getMouseY
protected double getMouseY()
Return the current y-coordinate of the mouse.- Returns:
- The y-coordinate of the mouse
-
setColor
public void setColor(javafx.scene.paint.Color pColor)
The background color of the window will be changed to specified color- Parameters:
pColor- The new background color
-
setColor
public void setColor(double pRed, double pGreen, double pBlue)The background color of the window 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 window 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 background color color
-
getColor
public javafx.scene.paint.Color getColor()
Return the current Backgroundcolor of this window- Returns:
- The background color
-
hasFocus
public boolean hasFocus()
Return true, if this windows currently has the focus.- Returns:
- Der Rückgabewert
-
alwaysOnTop
public void alwaysOnTop(boolean pOnTop)
Specify if this window is always on top of every other window.- Parameters:
true- : always on top is activate, false: always on top is deactivate
-
toFront
public void toFront()
Moves this window to the front of all other windows.
-
clear
public void clear()
Removes all drawings made by a pen from this window.
-
g
protected javafx.scene.canvas.GraphicsContext g()
The GraphicsOCntext of the canvas. Used by the pen.
-
setAppInstance
protected void setAppInstance(App pInstance)
Set the attribute appInstance to an instance of a subclass of App, which use this screen.
-
showGrid
public void showGrid()
Showing a grid for this windows. You can change the width between two ticks by changing the attribute gridXTicks and gridYTicks.
-
hideGrid
public void hideGrid()
Hides the grid.
-
gridToFront
protected void gridToFront()
Put the grid in the foreground.
-
setTitle
public void setTitle(String pTitle)
Set the title of this window to the specified name.- Parameters:
pTitle- The new window title
-
-