Package hsa

Class Console

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.WindowListener, java.util.EventListener

    public class Console
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Console()
      Creates a console using the default values of: 25x80 screen, 14 pt font, "Console" as title.
      Console​(int fontSize)
      Creates a console using the default values of: 25x80 screen, "Console" as title.
      Console​(int rows, int columns)
      Creates a console using the default values of: 14 pt font, "Console" as title.
      Console​(int rows, int columns, int fontSize)
      Creates a console using the default values of: "Console" as title.
      Console​(int rows, int columns, int fontSize, java.lang.String title)
      Creates a console.
      Console​(int rows, int columns, java.lang.String title)
      Creates a console using the default values of: 14 pt font.
      Console​(int fontSize, java.lang.String title)
      Creates a console using the default values of: 25x80 screen.
      Console​(java.lang.String title)
      Creates a console using the default values of: 25x80 screen, 14 pt font.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)
      Quits the program, saves the contents of the window, or prints the contents of the window, depending on which button is pressed.
      void clear()
      Clears the screen and moves the cursor to the top left corner.
      void clearRect​(int x, int y, int width, int height)
      Clears a rectangle in the console to white.
      void close()
      Closes the console window.
      void copyArea​(int x, int y, int width, int height, int delta_x, int delta_y)
      Copies an area of the screen from (x, y) to (x + width, y + height) onto the screen with top corner at (x + delta_x, y + delta_y).
      void draw3DRect​(int x, int y, int width, int height, boolean raised)
      Draws a 3D rectangle on the screen from (x, y) to (x + width, y + width).
      void drawArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
      Draws an arc on the screen from (x, y) to (x + width, y + height) from startAngle to startAngle + arcAngle in specified colour.
      void drawImage​(java.awt.Image img, int x, int y, java.awt.image.ImageObserver obs)
      Draws an image on the screen at (x, y).
      void drawLine​(int x1, int y1, int x2, int y2)
      Draws a line on the screen from (x1, y1) to (x2, y2).
      void drawMapleLeaf​(int x, int y, int width, int height)
      Draws a maple leaf on the screen from (x, y) to (x + width, y + width).
      void drawOval​(int x, int y, int width, int height)
      Draws an oval on the screen in the sqaure from (x, y) to (x + width, y + height).
      void drawPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Draws a polygon specified by the arrays of points.
      void drawRect​(int x, int y, int width, int height)
      Draws a rectangle on the screen from (x, y) to (x + width, y + width).
      void drawRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Draws a rounded rectangle on the screen from (x, y) to (x + width, y + width).
      void drawStar​(int x, int y, int width, int height)
      Draws a star on the screen from (x, y) to (x + width, y + width).
      void drawString​(java.lang.String str, int x, int y)
      Draws a text on the screen at location (x, y).
      protected void enableButtons​(boolean enable)
      Enables or disables all the buttons in the Console.
      protected void eraseLineOfInput()
      Erases the entire line of input.
      protected void erasePreviousChar()
      Erases the previous character in a line of input.
      void fill3DRect​(int x, int y, int width, int height, boolean raised)
      Draws a filled 3D rectangle on the screen from (x, y) to (x + width, y + width).
      void fillArc​(int x, int y, int width, int height, int startAngle, int arcAngle)
      Draws a filled arc on the screen from (x, y) to (x + width, y + height) from startAngle to startAngle + arcAngle in specified colour.
      void fillMapleLeaf​(int x, int y, int width, int height)
      Draws a filled maple leaf on the screen from (x, y) to (x + width, y + width).
      void fillOval​(int x, int y, int width, int height)
      Draws a filled oval on the screen in the sqaure from (x, y) to (x + width, y + height).
      void fillPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Draws a filled polygon specified by the arrays of points..
      void fillRect​(int x, int y, int width, int height)
      Draws a filled rectangle on the screen from (x, y) to (x + width, y + width).
      void fillRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Draws a filled rounded rectangle on the screen from (x, y) to (x + width, y + width).
      void fillStar​(int x, int y, int width, int height)
      Draws a filled star on the screen from (x, y) to (x + width, y + width).
      void focusGained​(java.awt.event.FocusEvent e)
      Sets the focus to the invisible button and then the console canvas.
      void focusLost​(java.awt.event.FocusEvent e)
      Does nothing.
      char getChar()
      Returns the next character entered on the keyboard.
      int getColumn()
      Returns the current column number of the cursor.
      int getHeight()
      Returns the height of the console drawing surface in pixels.
      int getMaxColumns()
      Returns the number of columns in the console window.
      int getMaxRows()
      Returns the number of rows in the console window.
      int getRow()
      Returns the current row number of the cursor.
      int getWidth()
      Returns the width of the console drawing surface in pixels.
      protected void initialize​(int rows, int columns, int fontSize, java.lang.String title)
      Initializes the window.
      boolean isCharAvail()
      Returns whether a character is available in the keyboard buffer.
      void keyPressed​(java.awt.event.KeyEvent e)
      Places a keystroke in the keyboard buffer.
      void keyReleased​(java.awt.event.KeyEvent e)
      Does nothing.
      void keyTyped​(java.awt.event.KeyEvent e)
      Does nothing.
      static void mainReturned()  
      protected void mainStopped()
      This method is invoked if the "main" method appears to have stopped executing.
      int maxcol()
      Returns the number of columns in the console window.
      int maxrow()
      Returns the number of rows in the console window.
      int maxx()
      Returns the maximum x coordinate of the console window in pixels.
      int maxy()
      Returns the maximum y coordinate of the console window in pixels.
      void print​(boolean value)
      Writes the text representation of a boolean to the Console.
      void print​(boolean value, int fieldSize)
      Writes the text representation of a boolean to the Console with a specified field size.
      void print​(byte number)
      Writes the text representation of an 8-bit integer (a "byte") to the Console.
      void print​(byte number, int fieldSize)
      Writes the text representation of an 8-bit integer (a "byte") to the Console with a specified field size.
      void print​(char ch)
      Writes a character to the Console.
      void print​(char ch, int fieldSize)
      Writes a character to the Console with a specified field size..
      void print​(double number)
      Writes a double precision floating point number (a "double") to the Console.
      void print​(double number, int fieldSize)
      Writes a double precision floating point number (a "double") to the Console with a specified field size.
      void print​(double number, int fieldSize, int decimalPlaces)
      Writes a double precision floating point number (a "double") to the Console with a specified field size and a specified number of decimal places.
      void print​(float number)
      Writes a floating point number (a "float") to the Console.
      void print​(float number, int fieldSize)
      Writes a floating point number (a "float") to the Console with a specified field size.
      void print​(float number, int fieldSize, int decimalPlaces)
      Writes a floating point number (a "double") to the Console with a specified field size and a specified number of decimal places.
      void print​(int number)
      Writes the text representation of an 32-bit integer (an "int") to the Console.
      void print​(int number, int fieldSize)
      Writes the text representation of an 32-bit integer (an "int") to the Console with a specified field size.
      void print​(long number)
      Writes the text representation of an 64-bit integer (a "long") to the Console.
      void print​(long number, int fieldSize)
      Writes the text representation of an 64-bit integer (a "long") to the Console with a specified field size.
      void print​(short number)
      Writes the text representation of an 16-bit integer (a "short") to the Console.
      void print​(short number, int fieldSize)
      Writes the text representation of an 16-bit integer (a "short") to the Console with a specified field size.
      void print​(java.lang.String text)
      Write a string to the Console.
      void print​(java.lang.String text, int fieldSize)
      Writes a string to the Console with a specified field size..
      void println()
      Writes a newline to the Console.
      void println​(boolean value)
      Writes the text representation of a boolean to the Console followed by a newline.
      void println​(boolean value, int fieldSize)
      Writes the text representation of a boolean to the Console with a specified field size followed by a newline.
      void println​(byte number)
      Writes the text representation of an 8-bit integer (a "byte") to the Console followed by a newline.
      void println​(byte number, int fieldSize)
      Writes the text representation of an 8-bit integer (a "byte") to the Console with a specified field size followed by a newline.
      void println​(char ch)
      Writes a character to the Console followed by a newline.
      void println​(char ch, int fieldSize)
      Writes a character to the Console with a specified field size..
      void println​(double number)
      Writes a double precision floating point number (a "double") to the Console followed by a newline.
      void println​(double number, int fieldSize)
      Writes a double precision floating point number (a "double") to the Console with a specified field size followed by a newline.
      void println​(double number, int fieldSize, int decimalPlaces)
      Writes a double precision floating point number (a "double") to the Console with a specified field size and a specified number of decimal places followed by a newline.
      void println​(float number)
      Writes a floating point number (a "float") to the Console followed by a newline.
      void println​(float number, int fieldSize)
      Writes a floating point number (a "float") to the Console with a specified field size followed by a newline.
      void println​(float number, int fieldSize, int decimalPlaces)
      Writes a floating point number (a "double") to the Console with a specified field size and a specified number of decimal places followed by a newline.
      void println​(int number)
      Writes the text representation of an 32-bit integer (an "int") to the Console followed by a newline.
      void println​(int number, int fieldSize)
      Writes the text representation of an 32-bit integer (an "int") to the Console with a specified field size followed by a newline.
      void println​(long number)
      Writes the text representation of an 64-bit integer (a "long") to the Console followed by a newline.
      void println​(long number, int fieldSize)
      Writes the text representation of an 64-bit integer (a "long") to the Console with a specified field size followed by a newline.
      void println​(short number)
      Writes the text representation of an 16-bit integer (a "short") to the Console followed by a newline.
      void println​(short number, int fieldSize)
      Writes the text representation of an 16-bit integer (a "short") to the Console with a specified field size followed by a newline.
      void println​(java.lang.String text)
      Writes a string to the Console followed by a newline.
      void println​(java.lang.String text, int fieldSize)
      Writes a string to the Console with a specified field size followed by a newline.
      protected void quitProgram()
      Hides the window and quits the program.
      boolean readBoolean()
      Reads a boolean from the Console.
      byte readByte()
      Reads an 8-bit integer (a "byte") from the Console.
      char readChar()
      Reads a single character from the Console.
      double readDouble()
      Reads a double precision floating point number (a "double") from the Console.
      float readFloat()
      Reads a floating point number (a "float") from the Console.
      int readInt()
      Reads a 32-bit integer (an "int") from the Console.
      java.lang.String readLine()
      Reads a full line of text from the Console.
      long readLong()
      Reads a 64-bit integer (a "long") from the Console.
      short readShort()
      Reads a 16-bit integer (a "short") from the Console.
      java.lang.String readString()
      Reads a whitespace delimited token from the Console.
      protected java.lang.String readToken()
      Reads in input from the keyboard buffer until it hits a whitespace, which indicates the end of a token.
      void setColor​(java.awt.Color color)
      Sets the foreground color for any graphics.
      void setColour​(java.awt.Color colour)
      Sets the foreground colour for any graphics.
      void setCursor​(int row, int column)
      Moves the cursor to the specified row and column.
      void setCursorVisible​(boolean visible)
      Makes the blinking cursor visible or invisible.
      void setFont​(java.awt.Font font)
      Sets the font for the drawString method.
      void setPaintMode()
      Sets the drawing mode for any graphics to "Paint".
      void setTextBackgroundColor​(java.awt.Color color)
      Sets the background color for any text.
      void setTextBackgroundColour​(java.awt.Color colour)
      Sets the background color for any text.
      void setTextColor​(java.awt.Color color)
      Sets the foreground color for any text.
      void setTextColour​(java.awt.Color colour)
      Sets the foreground colour for any text.
      protected void setWindowTitle​(java.lang.String s)
      Sets the window title.
      void setXORMode​(java.awt.Color xorColor)
      Sets the drawing mode for any graphics to "XOR".
      void windowActivated​(java.awt.event.WindowEvent e)
      Does nothing.
      void windowClosed​(java.awt.event.WindowEvent e)
      Does nothing.
      void windowClosing​(java.awt.event.WindowEvent e)
      Quits the program.
      void windowDeactivated​(java.awt.event.WindowEvent e)
      Does nothing.
      void windowDeiconified​(java.awt.event.WindowEvent e)
      Does nothing.
      void windowIconified​(java.awt.event.WindowEvent e)
      Does nothing.
      void windowOpened​(java.awt.event.WindowEvent e)
      Does nothing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • currentRow

        protected int currentRow
        Console text variables
      • currentCol

        protected int currentCol
        Console text variables
      • actualRow

        protected int actualRow
      • actualCol

        protected int actualCol
      • startCol

        protected int startCol
      • startRow

        protected int startRow
      • textColor

        protected java.awt.Color textColor
      • textBGColor

        protected java.awt.Color textBGColor
      • echoOn

        protected boolean echoOn
      • clearToEOL

        protected boolean clearToEOL
      • graphicsColor

        protected java.awt.Color graphicsColor
        Console graphics variables
      • font

        protected java.awt.Font font
      • graphicsCanvas

        protected hsa.ConsoleCanvasGraphics graphicsCanvas
      • mainReturned

        protected static boolean mainReturned
      • window

        protected hsa.ConsoleFrame window
      • maxRow

        protected int maxRow
      • maxCol

        protected int maxCol
      • kbdBuffer

        protected char[] kbdBuffer
      • kbdBufferHead

        protected int kbdBufferHead
      • kbdBufferTail

        protected int kbdBufferTail
      • lineBuffer

        protected char[] lineBuffer
      • lineBufferHead

        protected int lineBufferHead
      • lineBufferTail

        protected int lineBufferTail
      • ungotChar

        protected int ungotChar
      • consoleCanvasPanelInner

        protected java.awt.Panel consoleCanvasPanelInner
      • eofReached

        protected boolean eofReached
    • Constructor Detail

      • Console

        public Console()
        Creates a console using the default values of: 25x80 screen, 14 pt font, "Console" as title.
      • Console

        public Console​(int fontSize)
        Creates a console using the default values of: 25x80 screen, "Console" as title.
        Parameters:
        fontSize - The size of the font to be used in the Console window
      • Console

        public Console​(int rows,
                       int columns)
        Creates a console using the default values of: 14 pt font, "Console" as title.
        Parameters:
        rows - The height of the window in rows
        columns - The width of the window in columns
      • Console

        public Console​(int rows,
                       int columns,
                       int fontSize)
        Creates a console using the default values of: "Console" as title.
        Parameters:
        rows - The height of the window in rows
        columns - The width of the window in columns
        fontSize - The size of the font to be used in the Console window
      • Console

        public Console​(int rows,
                       int columns,
                       int fontSize,
                       java.lang.String title)
        Creates a console.
        Parameters:
        rows - The height of the window in rows
        columns - The width of the window in columns
        fontSize - The size of the font to be used in the Console window
        title - The title of the Console window
      • Console

        public Console​(int rows,
                       int columns,
                       java.lang.String title)
        Creates a console using the default values of: 14 pt font.
        Parameters:
        rows - The height of the window in rows
        columns - The width of the window in columns
        title - The title of the Console window
      • Console

        public Console​(int fontSize,
                       java.lang.String title)
        Creates a console using the default values of: 25x80 screen.
        Parameters:
        fontSize - The size of the font to be used in the Console window.
        title - The title of the Console window.
      • Console

        public Console​(java.lang.String title)
        Creates a console using the default values of: 25x80 screen, 14 pt font.
        Parameters:
        title - The title of the Console window
    • Method Detail

      • clear

        public void clear()
        Clears the screen and moves the cursor to the top left corner.
      • clearRect

        public void clearRect​(int x,
                              int y,
                              int width,
                              int height)
        Clears a rectangle in the console to white.
        See Also:
        java.awt.Graphics.clearRect
      • copyArea

        public void copyArea​(int x,
                             int y,
                             int width,
                             int height,
                             int delta_x,
                             int delta_y)
        Copies an area of the screen from (x, y) to (x + width, y + height) onto the screen with top corner at (x + delta_x, y + delta_y).
        See Also:
        java.awt.Graphics.copyArea
      • draw3DRect

        public void draw3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)
        Draws a 3D rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.draw3DRect
      • drawArc

        public void drawArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Draws an arc on the screen from (x, y) to (x + width, y + height) from startAngle to startAngle + arcAngle in specified colour.
        See Also:
        java.awt.Graphics.drawArc
      • drawImage

        public void drawImage​(java.awt.Image img,
                              int x,
                              int y,
                              java.awt.image.ImageObserver obs)
        Draws an image on the screen at (x, y).
        See Also:
        java.awt.Graphics.drawImage
      • drawLine

        public void drawLine​(int x1,
                             int y1,
                             int x2,
                             int y2)
        Draws a line on the screen from (x1, y1) to (x2, y2).
        See Also:
        java.awt.Graphics.drawLine
      • drawMapleLeaf

        public void drawMapleLeaf​(int x,
                                  int y,
                                  int width,
                                  int height)
        Draws a maple leaf on the screen from (x, y) to (x + width, y + width).
        Parameters:
        x - The x coordinate of the top left corner of the rectangle that the maple leaf is inscribed in.
        y - The y coordinate of the top left corner of the rectangle that the maple leaf is inscribed in.
        width - The width of the rectangle that the maple leaf is inscribed in.
        height - The height of the rectangle that the maple leaf is inscribed in.
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int width,
                             int height)
        Draws an oval on the screen in the sqaure from (x, y) to (x + width, y + height).
        See Also:
        java.awt.Graphics.drawOval
      • drawPolygon

        public void drawPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Draws a polygon specified by the arrays of points.
        See Also:
        java.awt.Graphics.drawPolygon
      • drawRect

        public void drawRect​(int x,
                             int y,
                             int width,
                             int height)
        Draws a rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.drawRect
      • drawRoundRect

        public void drawRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Draws a rounded rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.drawRoundRect
      • drawStar

        public void drawStar​(int x,
                             int y,
                             int width,
                             int height)
        Draws a star on the screen from (x, y) to (x + width, y + width).
        Parameters:
        x - The x coordinate of the top left corner of the rectangle that the star is inscribed in.
        y - The y coordinate of the top left corner of the rectangle that the star is inscribed in.
        width - The width of the rectangle that the star is inscribed in.
        height - The height of the rectangle that the star is inscribed in.
      • drawString

        public void drawString​(java.lang.String str,
                               int x,
                               int y)
        Draws a text on the screen at location (x, y).
        See Also:
        java.awt.Graphics.drawString
      • eraseLineOfInput

        protected void eraseLineOfInput()
        Erases the entire line of input. Called when the user presses Ctrl+U when typing.
      • erasePreviousChar

        protected void erasePreviousChar()
        Erases the previous character in a line of input. Called when the user presses backspace when typing.
      • fill3DRect

        public void fill3DRect​(int x,
                               int y,
                               int width,
                               int height,
                               boolean raised)
        Draws a filled 3D rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.fill3DRect
      • fillArc

        public void fillArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Draws a filled arc on the screen from (x, y) to (x + width, y + height) from startAngle to startAngle + arcAngle in specified colour.
        See Also:
        java.awt.Graphics.fillArc
      • fillMapleLeaf

        public void fillMapleLeaf​(int x,
                                  int y,
                                  int width,
                                  int height)
        Draws a filled maple leaf on the screen from (x, y) to (x + width, y + width).
        Parameters:
        x - int The x coordinate of the top left corner of the rectangle that the maple leaf is inscribed in.
        y - int The y coordinate of the top left corner of the rectangle that the maple leaf is inscribed in.
        width - int The width of the rectangle that the maple leaf is inscribed in.
        height - int The height of the rectangle that the maple leaf is inscribed in.
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int width,
                             int height)
        Draws a filled oval on the screen in the sqaure from (x, y) to (x + width, y + height).
        See Also:
        java.awt.Graphics.fillOval
      • fillPolygon

        public void fillPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Draws a filled polygon specified by the arrays of points..
        See Also:
        java.awt.Graphics.fillPolygon
      • fillRect

        public void fillRect​(int x,
                             int y,
                             int width,
                             int height)
        Draws a filled rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.fillRect
      • fillRoundRect

        public void fillRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Draws a filled rounded rectangle on the screen from (x, y) to (x + width, y + width).
        See Also:
        java.awt.Graphics.fillRoundRect
      • fillStar

        public void fillStar​(int x,
                             int y,
                             int width,
                             int height)
        Draws a filled star on the screen from (x, y) to (x + width, y + width).
        Parameters:
        x - The x coordinate of the top left corner of the rectangle that the star is inscribed in.
        y - The y coordinate of the top left corner of the rectangle that the star is inscribed in.
        width - The width of the rectangle that the star is inscribed in.
        height - The height of the rectangle that the star is inscribed in.
      • isCharAvail

        public boolean isCharAvail()
        Returns whether a character is available in the keyboard buffer. Ignores characters currently in the line buffer.
        Returns:
        true if a character is ready to be read with getChar
      • getChar

        public char getChar()
        Returns the next character entered on the keyboard. Ignores characters currently in the line buffer.
        Returns:
        The next character entered on the keyboard.
      • getColumn

        public int getColumn()
        Returns the current column number of the cursor.
        Returns:
        The current column number of the cursor.
      • getHeight

        public int getHeight()
        Returns the height of the console drawing surface in pixels.
        Returns:
        The height of the console window in pixels.
      • getMaxColumns

        public int getMaxColumns()
        Returns the number of columns in the console window.
        Returns:
        The width of the screen in columns.
      • getMaxRows

        public int getMaxRows()
        Returns the number of rows in the console window.
        Returns:
        The height of the screen in rows.
      • getRow

        public int getRow()
        Returns the current row number of the cursor.
        Returns:
        The current row number of the cursor.
      • getWidth

        public int getWidth()
        Returns the width of the console drawing surface in pixels.
        Returns:
        The width of the console drawing surface in pixels.
      • maxcol

        public int maxcol()
        Returns the number of columns in the console window.
        Returns:
        The width of the screen in columns.
      • maxrow

        public int maxrow()
        Returns the number of rows in the console window.
        Returns:
        The height of the screen in rows.
      • maxx

        public int maxx()
        Returns the maximum x coordinate of the console window in pixels. Available for compatibility with first printing of "Programming Concepts"
        Returns:
        The maximum x coordinate of the console window in pixels.
      • maxy

        public int maxy()
        Returns the maximum y coordinate of the console window in pixels. Available for compatibility with first printing of "Programming Concepts"
        Returns:
        The maximum y coordinate the console window in pixels.
      • print

        public void print​(java.lang.String text)
        Write a string to the Console.
        Parameters:
        text - The string to be written to the Console
      • readChar

        public char readChar()
        Reads a single character from the Console. Note that this discards any whitespace. If you want to get every character on the line, use the readLine () method.
        Returns:
        The character read from the Console
      • setColor

        public void setColor​(java.awt.Color color)
        Sets the foreground color for any graphics.
        See Also:
        java.awt.Graphics.setColor
      • setColour

        public void setColour​(java.awt.Color colour)
        Sets the foreground colour for any graphics.
        See Also:
        java.awt.Graphics.setColor
      • setCursor

        public void setCursor​(int row,
                              int column)
        Moves the cursor to the specified row and column.
        Parameters:
        row - The row to move the cursor to
        column - The column to move the cursor to
      • setCursorVisible

        public void setCursorVisible​(boolean visible)
        Makes the blinking cursor visible or invisible.
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font for the drawString method.
        See Also:
        java.awt.Graphics.setFont
      • setPaintMode

        public void setPaintMode()
        Sets the drawing mode for any graphics to "Paint".
        See Also:
        java.awt.Graphics.setPaintMode
      • setTextBackgroundColor

        public void setTextBackgroundColor​(java.awt.Color color)
        Sets the background color for any text.
        Parameters:
        color - The color that text displayed by print and println methods will appear on.
      • setTextBackgroundColour

        public void setTextBackgroundColour​(java.awt.Color colour)
        Sets the background color for any text.
        Parameters:
        colour - The color that text displayed by print and println methods will appear on.
      • setTextColor

        public void setTextColor​(java.awt.Color color)
        Sets the foreground color for any text.
        Parameters:
        color - The color that text displayed by print and println methods will appear in.
      • setTextColour

        public void setTextColour​(java.awt.Color colour)
        Sets the foreground colour for any text.
        Parameters:
        colour - The color that text displayed by print and println methods will appear in.
      • setXORMode

        public void setXORMode​(java.awt.Color xorColor)
        Sets the drawing mode for any graphics to "XOR".
        See Also:
        java.awt.Graphics.setXORMode
      • mainReturned

        public static void mainReturned()
      • initialize

        protected void initialize​(int rows,
                                  int columns,
                                  int fontSize,
                                  java.lang.String title)
        Initializes the window. Not in the constructor because it needs certain elements that are not ready at construction time.
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Quits the program, saves the contents of the window, or prints the contents of the window, depending on which button is pressed. Called by the system when a button in the Console is pressed.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • close

        public void close()
        Closes the console window.
      • enableButtons

        protected void enableButtons​(boolean enable)
        Enables or disables all the buttons in the Console. Used while the contents of the window is being saved or printed.
      • focusGained

        public void focusGained​(java.awt.event.FocusEvent e)
        Sets the focus to the invisible button and then the console canvas. This is necessary as a work-around to a bug in VisualAge for Java, which gives buttons default focus that can only be removed by making another button a focus. Called by the system when the Console gains focus.
        Specified by:
        focusGained in interface java.awt.event.FocusListener
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        Does nothing. Called by the system when the Console loses focus.
        Specified by:
        focusLost in interface java.awt.event.FocusListener
      • keyPressed

        public void keyPressed​(java.awt.event.KeyEvent e)
        Places a keystroke in the keyboard buffer. It is synchronized so that there can't be a problem with input being taken off the keyboard buffer and placed on the keyboard buffer at the same time.
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
      • keyReleased

        public void keyReleased​(java.awt.event.KeyEvent e)
        Does nothing. Called by the system when a key is released.
        Specified by:
        keyReleased in interface java.awt.event.KeyListener
      • keyTyped

        public void keyTyped​(java.awt.event.KeyEvent e)
        Does nothing. Called by the system when a key is typed.
        Specified by:
        keyTyped in interface java.awt.event.KeyListener
      • mainStopped

        protected void mainStopped()
        This method is invoked if the "main" method appears to have stopped executing. This helps the user realize when the program has finished execution.
      • print

        public void print​(byte number)
        Writes the text representation of an 8-bit integer (a "byte") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(byte number,
                          int fieldSize)
        Writes the text representation of an 8-bit integer (a "byte") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(char ch)
        Writes a character to the Console.
        Parameters:
        ch - The character to be written to the Console.
      • print

        public void print​(char ch,
                          int fieldSize)
        Writes a character to the Console with a specified field size..
        Parameters:
        ch - The character to be written to the Console.
        fieldSize - The field width that the character is to be written in.
      • print

        public void print​(double number)
        Writes a double precision floating point number (a "double") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(double number,
                          int fieldSize)
        Writes a double precision floating point number (a "double") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(double number,
                          int fieldSize,
                          int decimalPlaces)
        Writes a double precision floating point number (a "double") to the Console with a specified field size and a specified number of decimal places.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
        decimalPlaces - The number of decimal places of the number to be displayed.
      • print

        public void print​(float number)
        Writes a floating point number (a "float") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(float number,
                          int fieldSize)
        Writes a floating point number (a "float") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(float number,
                          int fieldSize,
                          int decimalPlaces)
        Writes a floating point number (a "double") to the Console with a specified field size and a specified number of decimal places.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
        decimalPlaces - The number of decimal places of the number to be displayed.
      • print

        public void print​(int number)
        Writes the text representation of an 32-bit integer (an "int") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(int number,
                          int fieldSize)
        Writes the text representation of an 32-bit integer (an "int") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(long number)
        Writes the text representation of an 64-bit integer (a "long") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(long number,
                          int fieldSize)
        Writes the text representation of an 64-bit integer (a "long") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(java.lang.String text,
                          int fieldSize)
        Writes a string to the Console with a specified field size..
        Parameters:
        text - The string to be written to the Console.
        fieldSize - The field width that the string is to be written in.
      • print

        public void print​(short number)
        Writes the text representation of an 16-bit integer (a "short") to the Console.
        Parameters:
        number - The number to be written to the Console.
      • print

        public void print​(short number,
                          int fieldSize)
        Writes the text representation of an 16-bit integer (a "short") to the Console with a specified field size.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • print

        public void print​(boolean value)
        Writes the text representation of a boolean to the Console.
        Parameters:
        value - The boolean to be written to the Console.
      • print

        public void print​(boolean value,
                          int fieldSize)
        Writes the text representation of a boolean to the Console with a specified field size.
        Parameters:
        value - The boolean to be written to the Console.
        fieldSize - The field width that the boolean is to be written in.
      • println

        public void println()
        Writes a newline to the Console.
      • println

        public void println​(byte number)
        Writes the text representation of an 8-bit integer (a "byte") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(byte number,
                            int fieldSize)
        Writes the text representation of an 8-bit integer (a "byte") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(char ch)
        Writes a character to the Console followed by a newline.
        Parameters:
        ch - The character to be written to the Console.
      • println

        public void println​(char ch,
                            int fieldSize)
        Writes a character to the Console with a specified field size..
        Parameters:
        ch - The character to be written to the Console.
        fieldSize - The field width that the character is to be written in.
      • println

        public void println​(double number)
        Writes a double precision floating point number (a "double") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(double number,
                            int fieldSize)
        Writes a double precision floating point number (a "double") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(double number,
                            int fieldSize,
                            int decimalPlaces)
        Writes a double precision floating point number (a "double") to the Console with a specified field size and a specified number of decimal places followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
        decimalPlaces - The number of decimal places of the number to be displayed.
      • println

        public void println​(float number)
        Writes a floating point number (a "float") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(float number,
                            int fieldSize)
        Writes a floating point number (a "float") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(float number,
                            int fieldSize,
                            int decimalPlaces)
        Writes a floating point number (a "double") to the Console with a specified field size and a specified number of decimal places followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
        decimalPlaces - The number of decimal places of the number to be displayed.
      • println

        public void println​(int number)
        Writes the text representation of an 32-bit integer (an "int") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(int number,
                            int fieldSize)
        Writes the text representation of an 32-bit integer (an "int") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(long number)
        Writes the text representation of an 64-bit integer (a "long") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(long number,
                            int fieldSize)
        Writes the text representation of an 64-bit integer (a "long") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(java.lang.String text)
        Writes a string to the Console followed by a newline.
        Parameters:
        text - The string to be written to the Console.
      • println

        public void println​(java.lang.String text,
                            int fieldSize)
        Writes a string to the Console with a specified field size followed by a newline.
        Parameters:
        text - The string to be written to the Console.
        fieldSize - The field width that the string is to be written in.
      • println

        public void println​(short number)
        Writes the text representation of an 16-bit integer (a "short") to the Console followed by a newline.
        Parameters:
        number - The number to be written to the Console.
      • println

        public void println​(short number,
                            int fieldSize)
        Writes the text representation of an 16-bit integer (a "short") to the Console with a specified field size followed by a newline.
        Parameters:
        number - The number to be written to the Console.
        fieldSize - The field width that the number is to be written in.
      • println

        public void println​(boolean value)
        Writes the text representation of a boolean to the Console followed by a newline.
        Parameters:
        value - The boolean to be written to the Console.
      • println

        public void println​(boolean value,
                            int fieldSize)
        Writes the text representation of a boolean to the Console with a specified field size followed by a newline.
        Parameters:
        value - The boolean to be written to the Console.
        fieldSize - The field width that the boolean is to be written in.
      • quitProgram

        protected void quitProgram()
        Hides the window and quits the program.
      • readBoolean

        public boolean readBoolean()
        Reads a boolean from the Console. The actual text in the Console must be either "true" or "false" although case is irrelvant.
        Returns:
        The boolean value read from the Console.
      • readByte

        public byte readByte()
        Reads an 8-bit integer (a "byte") from the Console. The actual text in the Console must be a number from -128 to 127.
        Returns:
        The byte value read from the Console.
      • readDouble

        public double readDouble()
        Reads a double precision floating point number (a "double") from the Console.
        Returns:
        The double value read from the Console.
      • readFloat

        public float readFloat()
        Reads a floating point number (a "float") from the Console.
        Returns:
        The float value read from the Console.
      • readInt

        public int readInt()
        Reads a 32-bit integer (an "int") from the Console. The actual text in the Console must be a number from -2147483648 to 2147483647.
        Returns:
        The int value read from the Console.
      • readLine

        public java.lang.String readLine()
        Reads a full line of text from the Console.
        Returns:
        The line of text read from the Console.
      • readLong

        public long readLong()
        Reads a 64-bit integer (a "long") from the Console.
        Returns:
        The long value read from the Console.
      • readShort

        public short readShort()
        Reads a 16-bit integer (a "short") from the Console. The actual text in the Console must be a number from -32768 to 32767.
        Returns:
        The short value read from the Console.
      • readString

        public java.lang.String readString()
        Reads a whitespace delimited token from the Console.
        Returns:
        The token read from the Console.
      • readToken

        protected java.lang.String readToken()
        Reads in input from the keyboard buffer until it hits a whitespace, which indicates the end of a token.
      • setWindowTitle

        protected void setWindowTitle​(java.lang.String s)
        Sets the window title.
        Parameters:
        e - The window event
      • windowActivated

        public void windowActivated​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been activated.
        Specified by:
        windowActivated in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowClosed

        public void windowClosed​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been closed (dispose () has been called).
        Specified by:
        windowClosed in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowClosing

        public void windowClosing​(java.awt.event.WindowEvent e)
        Quits the program. Called by the system when the close box of the window has been clicked.
        Specified by:
        windowClosing in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowDeactivated

        public void windowDeactivated​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been deactivated.
        Specified by:
        windowDeactivated in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowDeiconified

        public void windowDeiconified​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been deminimized.
        Specified by:
        windowDeiconified in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowIconified

        public void windowIconified​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been minimized.
        Specified by:
        windowIconified in interface java.awt.event.WindowListener
        Parameters:
        e - The window event
      • windowOpened

        public void windowOpened​(java.awt.event.WindowEvent e)
        Does nothing. Called by the system after the window has been opened for the first time.
        Specified by:
        windowOpened in interface java.awt.event.WindowListener
        Parameters:
        e - The window event