Class Terminal
- java.lang.Object
-
- Core.Terminal
-
public class Terminal extends java.lang.Object
Builds an external terminal that is more intuitive and customizable than the normal IDE terminal- Version:
- 1.0.3-beta
- Author:
- TMG8047KG
-
-
Constructor Summary
Constructors Constructor Description Terminal()
Declares the terminal Default size 450x650 pixelsTerminal(int height, int width)
Declares the Terminal Defines the size of the TerminalTerminal(java.lang.String title)
Declares the terminal And sets the titleTerminal(java.lang.String title, int height, int width)
Declares the terminal Defines the size and the name of the Terminal
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKeyListener(java.awt.event.KeyListener listener)
AddsKeyListener
to the Terminalvoid
clear()
Clears the terminal by setting the text to nothingchar[][]
getCharMatrix()
Gets the char matrix if setjava.awt.Font
getFont()
Gives the set fontjavax.swing.JFrame
getFrame()
Gets the window builder of the Terminal class on which the terminal is createdint[][]
getIntMatrix()
Gets the int matrix if setTerminalScheduleUpdate
getSchedule()
Returns the set schedulejava.lang.String[][]
getStringMatrix()
Gets the string matrix if setboolean
isFullscreen()
Checks is the Terminal window fullscreenboolean
isResizeable()
Checks to see if the window is resizablevoid
print(java.lang.String text)
OutputsString
to the terminalvoid
print(java.lang.String text, int r, int g, int b)
OutputsString
to the terminal withColor
by selecting the rgb valuesvoid
print(java.lang.String text, java.awt.Color color)
OutputsString
to the terminal withColor
void
println()
OutputsString
to the terminal and makes a new linevoid
println(java.lang.String text)
OutputsString
to the terminal and makes a new linevoid
println(java.lang.String text, int r, int g, int b)
OutputsString
to the terminal and makes a new line withColor
by selecting the rgb valuesvoid
println(java.lang.String text, java.awt.Color color)
OutputsString
to the terminal and makes a new line withColor
void
printMatrix()
Prints the set matrix With some limitationsvoid
printMatrix(char[][] matrix)
Prints a char matrix in the Terminalvoid
printMatrix(char[][] matrix, boolean clean)
Clears the terminal and prints a char matrixvoid
printMatrix(int[][] matrix)
Prints an int matrix in the Terminalvoid
printMatrix(int[][] matrix, boolean clean)
Clears the terminal and prints an int matrixvoid
printMatrix(java.lang.String[][] matrix)
Prints a String matrix in the Terminalvoid
printMatrix(java.lang.String[][] matrix, boolean clean)
Clears the terminal and prints a String matrixjava.lang.String
readLine()
Reads the last line in the Terminal Limitations:void
removeKeyListener(java.awt.event.KeyListener listener)
Removes givenKeyListener
void
run()
Builds the terminal by executing all the specifications for thevoid
setBackgroundColor(int r, int g, int b)
void
setBackgroundColor(java.awt.Color backgroundColor)
Sets theColor
of the terminal backgroundvoid
setDelay(int delay)
Sets the delay between executions in the schedule (in milliseconds)void
setEditable(boolean editable)
Sets whether you can type in the consolevoid
setFont(java.awt.Font font)
Sets the font to a new onevoid
setFont(java.lang.String name)
Sets the font to a new onevoid
setFont(java.lang.String name, int style)
Sets the font to a new onevoid
setFont(java.lang.String name, int style, int size)
Sets the font to a new onevoid
setFontColor(int r, int g, int b)
Sets the font color to a new onevoid
setFontColor(java.awt.Color fontColor)
Sets theColor
of the terminal fontvoid
setFontSize(int fontSize)
Changes the size of the fontvoid
setFullscreen(boolean fullscreen)
Makes the Terminal window fullscreenvoid
setInitialDelay(int initialDelay)
Sets the initial delay for the schedule (in milliseconds)void
setMatrix(char[][] charMatrix)
Sets matrix that can be printedvoid
setMatrix(int[][] intMatrix)
Sets matrix that can be printedvoid
setMatrix(java.lang.String[][] stringMatrix)
Sets matrix that can be printedvoid
setResizeable(boolean resizeable)
Sets whether the Terminal window is resizable by the user On default is: truevoid
setSchedule(TerminalScheduleUpdate scheduleUpdate)
Sets the periodic execution(schedule) for the terminalvoid
setText(java.lang.String text)
Sets or overrides all the text shown in the terminalvoid
start()
Starts the update schedulevoid
stop()
Closes the terminalvoid
stopUpdate()
Stops the schedule from running
-
-
-
Constructor Detail
-
Terminal
public Terminal()
Declares the terminal Default size 450x650 pixels
-
Terminal
public Terminal(java.lang.String title)
Declares the terminal And sets the title- Parameters:
title
- Title
-
Terminal
public Terminal(int height, int width)
Declares the Terminal Defines the size of the Terminal- Parameters:
height
- The height in pixelswidth
- The width in pixels
-
Terminal
public Terminal(java.lang.String title, int height, int width)
Declares the terminal Defines the size and the name of the Terminal- Parameters:
title
- Titleheight
- The height in pixelswidth
- The width in pixels
-
-
Method Detail
-
getFrame
public javax.swing.JFrame getFrame()
Gets the window builder of the Terminal class on which the terminal is created- Returns:
- Returns the Terminal window builder
-
getSchedule
public TerminalScheduleUpdate getSchedule()
Returns the set schedule- Returns:
- Returns schedule
-
setSchedule
public void setSchedule(TerminalScheduleUpdate scheduleUpdate)
Sets the periodic execution(schedule) for the terminalThis method executes by default 2 times in a second you can change the value of the delay to change how many times in a second to execute
Documentation on how use watch the GitHub- Parameters:
scheduleUpdate
- adds newTerminalScheduleUpdate
-
setDelay
public void setDelay(int delay)
Sets the delay between executions in the schedule (in milliseconds)- Parameters:
delay
- delay in milliseconds
-
setInitialDelay
public void setInitialDelay(int initialDelay)
Sets the initial delay for the schedule (in milliseconds)- Parameters:
initialDelay
- delay in milliseconds
-
start
public void start()
Starts the update scheduleThis starts a loop that constantly executes the update method from
TerminalScheduleUpdate
-
stopUpdate
public void stopUpdate()
Stops the schedule from running
-
addKeyListener
public void addKeyListener(java.awt.event.KeyListener listener)
AddsKeyListener
to the TerminalYou have to build your KeyListener before you add it
- Parameters:
listener
- addsKeyListener
- See Also:
KeyListener
-
removeKeyListener
public void removeKeyListener(java.awt.event.KeyListener listener)
Removes givenKeyListener
- Parameters:
listener
- Removes listener
-
setEditable
public void setEditable(boolean editable)
Sets whether you can type in the console- Parameters:
editable
- Enables/Disables editing
-
setMatrix
public void setMatrix(int[][] intMatrix)
Sets matrix that can be printed- Parameters:
intMatrix
- set matrix- See Also:
printMatrix()
-
setMatrix
public void setMatrix(char[][] charMatrix)
Sets matrix that can be printed- Parameters:
charMatrix
- set matrix- See Also:
printMatrix()
-
setMatrix
public void setMatrix(java.lang.String[][] stringMatrix)
Sets matrix that can be printed- Parameters:
stringMatrix
- set matrix- See Also:
printMatrix()
-
printMatrix
public void printMatrix(char[][] matrix, boolean clean)
Clears the terminal and prints a char matrix- Parameters:
matrix
- matrixclean
- cleans the terminal
-
printMatrix
public void printMatrix(int[][] matrix, boolean clean)
Clears the terminal and prints an int matrix- Parameters:
matrix
- matrixclean
- cleans the terminal
-
printMatrix
public void printMatrix(java.lang.String[][] matrix, boolean clean)
Clears the terminal and prints a String matrix- Parameters:
matrix
- matrixclean
- cleans the terminal
-
printMatrix
public void printMatrix(char[][] matrix)
Prints a char matrix in the Terminal- Parameters:
matrix
- matrix
-
printMatrix
public void printMatrix(int[][] matrix)
Prints an int matrix in the Terminal- Parameters:
matrix
- matrix
-
printMatrix
public void printMatrix(java.lang.String[][] matrix)
Prints a String matrix in the Terminal- Parameters:
matrix
- matrix
-
printMatrix
public void printMatrix()
Prints the set matrix With some limitations
-
getIntMatrix
public int[][] getIntMatrix()
Gets the int matrix if set- Returns:
- int matrix
-
getCharMatrix
public char[][] getCharMatrix()
Gets the char matrix if set- Returns:
- char matrix
-
getStringMatrix
public java.lang.String[][] getStringMatrix()
Gets the string matrix if set- Returns:
- string matrix
-
stop
public void stop()
Closes the terminal
-
setText
public void setText(java.lang.String text)
Sets or overrides all the text shown in the terminal- Parameters:
text
- sets text
-
print
public void print(java.lang.String text, int r, int g, int b)
OutputsString
to the terminal withColor
by selecting the rgb values- Parameters:
text
- output textr
- redg
- greenb
- blue
-
print
public void print(java.lang.String text, java.awt.Color color)
OutputsString
to the terminal withColor
- Parameters:
text
- output textcolor
- color
-
print
public void print(java.lang.String text)
OutputsString
to the terminal- Parameters:
text
- output text
-
println
public void println()
OutputsString
to the terminal and makes a new line
-
println
public void println(java.lang.String text)
OutputsString
to the terminal and makes a new line- Parameters:
text
- output text
-
println
public void println(java.lang.String text, int r, int g, int b)
OutputsString
to the terminal and makes a new line withColor
by selecting the rgb values- Parameters:
text
- output textr
- redg
- greenb
- blue
-
println
public void println(java.lang.String text, java.awt.Color color)
OutputsString
to the terminal and makes a new line withColor
- Parameters:
text
- output textcolor
- color
-
clear
public void clear()
Clears the terminal by setting the text to nothing
-
readLine
public java.lang.String readLine()
Reads the last line in the Terminal Limitations:Pasting text with more than one line is not going to read the lines on top Always reads the last line even if nothing is typed Stops the execution for the most of the things
- Returns:
- Last line in the Terminal
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color backgroundColor)
Sets theColor
of the terminal background- Parameters:
backgroundColor
- set the backgroundColor
-
setBackgroundColor
public void setBackgroundColor(int r, int g, int b)
-
setFontSize
public void setFontSize(int fontSize)
Changes the size of the font- Parameters:
fontSize
- size
-
setFontColor
public void setFontColor(java.awt.Color fontColor)
Sets theColor
of the terminal font- Parameters:
fontColor
- sets the fontColor
-
setFontColor
public void setFontColor(int r, int g, int b)
Sets the font color to a new onethis can be done by selecting the rgb values of the color you want
- Parameters:
r
- redg
- greenb
- blue
-
setFont
public void setFont(java.awt.Font font)
Sets the font to a new oneThis is done by making a new
Font
object- Parameters:
font
- setsFont
-
setFont
public void setFont(java.lang.String name, int style, int size)
Sets the font to a new oneSets the font by giving it the name of the font as well as the desired style and size
The styles can be bold, italics and so on (default = 0)
- Parameters:
name
- the name of the fontstyle
- the style of the fontsize
- the font size
-
setFont
public void setFont(java.lang.String name, int style)
Sets the font to a new oneSets the font by giving it the name of the font as well as the desired style
The styles can be bold, italics and so on (default = 0)
- Parameters:
name
- the name of the fontstyle
- the style of the font
-
setFont
public void setFont(java.lang.String name)
Sets the font to a new oneSets the font by giving it the name of the font
- Parameters:
name
- the name of the font
-
getFont
public java.awt.Font getFont()
Gives the set font- Returns:
- font
-
setResizeable
public void setResizeable(boolean resizeable)
Sets whether the Terminal window is resizable by the user On default is: true- Parameters:
resizeable
- False to lock resizing
-
isResizeable
public boolean isResizeable()
Checks to see if the window is resizable- Returns:
- True if resizable, else false.
-
setFullscreen
public void setFullscreen(boolean fullscreen)
Makes the Terminal window fullscreen- Parameters:
fullscreen
- True for fullscreen
-
isFullscreen
public boolean isFullscreen()
Checks is the Terminal window fullscreen- Returns:
- False if not fullscreen
-
run
public void run()
Builds the terminal by executing all the specifications for the
-
-