Documentation of 'edu.princeton.cs.algs4.Draw' Java class
Draw
edu.princeton.cs.algs4

Class Draw

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener


    public final class Draw
    extends java.lang.Object
    implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener
    Draw. This class provides a basic capability for creating drawings with your programs. It uses a simple graphics model that allows you to create drawings consisting of points, lines, and curves in a window on your computer and to save the drawings to a file. This is the object-oriented version of standard draw; it supports multiple indepedent drawing windows.

    For additional documentation, see Section 3.1 of Computer Science: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.awt.Color BLACK
      The color black.
      static java.awt.Color BLUE
      The color blue.
      static java.awt.Color BOOK_BLUE
      Shade of blue used in Introduction to Programming in Java.
      static java.awt.Color BOOK_LIGHT_BLUE
      Shade of light blue used in Introduction to Programming in Java.
      static java.awt.Color BOOK_RED
      Shade of red used in Algorithms, 4th edition.
      static java.awt.Color CYAN
      The color cyan.
      static java.awt.Color DARK_GRAY
      The color dark gray.
      static java.awt.Color GRAY
      The color gray.
      static java.awt.Color GREEN
      The color green.
      static java.awt.Color LIGHT_GRAY
      The color light gray.
      static java.awt.Color MAGENTA
      The color magenta.
      static java.awt.Color ORANGE
      The color orange.
      static java.awt.Color PINK
      The color pink.
      static java.awt.Color PRINCETON_ORANGE
      Shade of orange used in Princeton's identity.
      static java.awt.Color RED
      The color red.
      static java.awt.Color WHITE
      The color white.
      static java.awt.Color YELLOW
      The color yellow.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Draw()
      Initializes an empty drawing object.
      Draw(java.lang.String name)
      Initializes an empty drawing object with the given name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      void actionPerformed(java.awt.event.ActionEvent e)
      This method cannot be called directly.
      void addListener(DrawListener listener)
      Adds a DrawListener to listen to keyboard and mouse events.
      void arc(double x, double y, double r, double angle1, double angle2)
      Draws an arc of radius r, centered on (x, y), from angle1 to angle2 (in degrees).
      void circle(double x, double y, double r)
      Draws a circle of radius r, centered on (x, y).
      void clear()
      Clears the screen to the default color (white).
      void clear(java.awt.Color color)
      Clears the screen to the given color.
      void disableDoubleBuffering()
      Disable double buffering.
      void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis)
      Draws an ellipse with given semimajor and semiminor axes, centered on (x, y).
      void enableDoubleBuffering()
      Enable double buffering.
      void filledCircle(double x, double y, double r)
      Draws a filled circle of radius r, centered on (x, y).
      void filledEllipse(double x, double y, double semiMajorAxis, double semiMinorAxis)
      Draws an ellipse with given semimajor and semiminor axes, centered on (x, y).
      void filledPolygon(double[] x, double[] y)
      Draws a filled polygon with the given (x[i], y[i]) coordinates.
      void filledRectangle(double x, double y, double halfWidth, double halfHeight)
      Draws a filled rectangle of given half width and half height, centered on (x, y).
      void filledSquare(double x, double y, double r)
      Draws a filled square of side length 2r, centered on (x, y).
      java.awt.Font getFont()
      Gets the current font.
      javax.swing.JLabel getJLabel()
      Gets the current JLabel for use in some other GUI.
      java.awt.Color getPenColor()
      Gets the current pen color.
      double getPenRadius()
      Gets the current pen radius.
      boolean hasNextKeyTyped()
      Returns true if the user has typed a key.
      boolean isKeyPressed(int keycode)
      Returns true if the keycode is being pressed.
      boolean isMousePressed()
      Returns true if the mouse is being pressed.
      void keyPressed(java.awt.event.KeyEvent e)
      This method cannot be called directly.
      void keyReleased(java.awt.event.KeyEvent e)
      This method cannot be called directly.
      void keyTyped(java.awt.event.KeyEvent e)
      This method cannot be called directly.
      void line(double x0, double y0, double x1, double y1)
      Draws a line from (x0, y0) to (x1, y1).
      static void main(java.lang.String[] args)
      Test client.
      void mouseClicked(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      void mouseDragged(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      void mouseEntered(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      void mouseExited(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      void mouseMoved(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      boolean mousePressed()
      Deprecated. 
      replaced by isMousePressed()
      void mousePressed(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      void mouseReleased(java.awt.event.MouseEvent e)
      This method cannot be called directly.
      double mouseX()
      Returns the x-coordinate of the mouse.
      double mouseY()
      Returns the y-coordinate of the mouse.
      char nextKeyTyped()
      The next key typed by the user.
      void pause(int t)
      Pause for t milliseconds.
      void picture(double x, double y, java.lang.String filename)
      Draws picture (gif, jpg, or png) centered on (x, y).
      void picture(double x, double y, java.lang.String filename, double degrees)
      Draws picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees.
      void picture(double x, double y, java.lang.String filename, double w, double h)
      Draws picture (gif, jpg, or png) centered on (x, y), rescaled to w-by-h.
      void picture(double x, double y, java.lang.String filename, double w, double h, double degrees)
      Draws picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees, rescaled to w-by-h.
      void point(double x, double y)
      Draws a point at (x, y).
      void polygon(double[] x, double[] y)
      Draws a polygon with the given (x[i], y[i]) coordinates.
      void rectangle(double x, double y, double halfWidth, double halfHeight)
      Draws a rectangle of given half width and half height, centered on (x, y).
      void save(java.lang.String filename)
      Saves this drawing to a file.
      void setCanvasSize(int canvasWidth, int canvasHeight)
      Sets the canvas (drawing area) to be width-by-height pixels.
      void setDefaultCloseOperation(int value)
      Sets the default close operation.
      void setFont()
      Sets the font to the default font (sans serif, 16 point).
      void setFont(java.awt.Font font)
      Sets the font to the given value.
      void setLocationOnScreen(int x, int y)
      Sets the upper-left hand corner of the drawing window to be (x, y), where (0, 0) is upper left.
      void setPenColor()
      Sets the pen color to the default color (black).
      void setPenColor(java.awt.Color color)
      Sets the pen color to the given color.
      void setPenColor(int red, int green, int blue)
      Sets the pen color to the given RGB color.
      void setPenRadius()
      Sets the pen size to the default (.002).
      void setPenRadius(double r)
      Sets the radius of the pen to the given size.
      void setXscale()
      Sets the x-scale to be the default (between 0.0 and 1.0).
      void setXscale(double min, double max)
      Sets the x-scale.
      void setYscale()
      Sets the y-scale to be the default (between 0.0 and 1.0).
      void setYscale(double min, double max)
      Sets the y-scale.
      void show()
      Copies offscreen buffer to onscreen buffer.
      void show(int t)
      Deprecated. 
      void square(double x, double y, double r)
      Draws a square of side length 2r, centered on (x, y).
      void text(double x, double y, java.lang.String s)
      Writes the given text string in the current font, centered on (x, y).
      void text(double x, double y, java.lang.String s, double degrees)
      Writes the given text string in the current font, centered on (x, y) and rotated by the specified number of degrees.
      void textLeft(double x, double y, java.lang.String s)
      Writes the given text string in the current font, left-aligned at (x, y).
      void xorOff()
      Turns off xor mode.
      void xorOn()
      Turns on xor mode.
      • Methods inherited from class java.lang.Object

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

      • BLACK

        public static final java.awt.Color BLACK
        The color black.
      • BLUE

        public static final java.awt.Color BLUE
        The color blue.
      • CYAN

        public static final java.awt.Color CYAN
        The color cyan.
      • DARK_GRAY

        public static final java.awt.Color DARK_GRAY
        The color dark gray.
      • GRAY

        public static final java.awt.Color GRAY
        The color gray.
      • GREEN

        public static final java.awt.Color GREEN
        The color green.
      • LIGHT_GRAY

        public static final java.awt.Color LIGHT_GRAY
        The color light gray.
      • MAGENTA

        public static final java.awt.Color MAGENTA
        The color magenta.
      • ORANGE

        public static final java.awt.Color ORANGE
        The color orange.
      • PINK

        public static final java.awt.Color PINK
        The color pink.
      • RED

        public static final java.awt.Color RED
        The color red.
      • WHITE

        public static final java.awt.Color WHITE
        The color white.
      • YELLOW

        public static final java.awt.Color YELLOW
        The color yellow.
      • BOOK_BLUE

        public static final java.awt.Color BOOK_BLUE
        Shade of blue used in Introduction to Programming in Java. It is Pantone 300U. The RGB values are approximately (9, 90, 166).
      • BOOK_LIGHT_BLUE

        public static final java.awt.Color BOOK_LIGHT_BLUE
        Shade of light blue used in Introduction to Programming in Java. The RGB values are approximately (103, 198, 243).
      • BOOK_RED

        public static final java.awt.Color BOOK_RED
        Shade of red used in Algorithms, 4th edition. It is Pantone 1805U. The RGB values are approximately (150, 35, 31).
      • PRINCETON_ORANGE

        public static final java.awt.Color PRINCETON_ORANGE
        Shade of orange used in Princeton's identity. It is PMS 158. The RGB values are approximately (245, 128, 37).
    • Constructor Detail

      • Draw

        public Draw(java.lang.String name)
        Initializes an empty drawing object with the given name.
        Parameters:
        name - the title of the drawing window.
      • Draw

        public Draw()
        Initializes an empty drawing object.
    • Method Detail

      • setLocationOnScreen

        public void setLocationOnScreen(int x,
                                        int y)
        Sets the upper-left hand corner of the drawing window to be (x, y), where (0, 0) is upper left.
        Parameters:
        x - the number of pixels from the left
        y - the number of pixels from the top
        Throws:
        java.lang.IllegalArgumentException - if the width or height is 0 or negative
      • setDefaultCloseOperation

        public void setDefaultCloseOperation(int value)
        Sets the default close operation.
        Parameters:
        value - the value, typically JFrame.EXIT_ON_CLOSE (close all windows) or JFrame.DISPOSE_ON_CLOSE (close current window)
      • setCanvasSize

        public void setCanvasSize(int canvasWidth,
                                  int canvasHeight)
        Sets the canvas (drawing area) to be width-by-height pixels. This also erases the current drawing and resets the coordinate system, pen radius, pen color, and font back to their default values. Ordinarly, this method is called once, at the very beginning of a program.
        Parameters:
        canvasWidth - the width as a number of pixels
        canvasHeight - the height as a number of pixels
        Throws:
        java.lang.IllegalArgumentException - unless both canvasWidth and canvasHeight are positive
      • setXscale

        public void setXscale()
        Sets the x-scale to be the default (between 0.0 and 1.0).
      • setYscale

        public void setYscale()
        Sets the y-scale to be the default (between 0.0 and 1.0).
      • setXscale

        public void setXscale(double min,
                              double max)
        Sets the x-scale.
        Parameters:
        min - the minimum value of the x-scale
        max - the maximum value of the x-scale
      • setYscale

        public void setYscale(double min,
                              double max)
        Sets the y-scale.
        Parameters:
        min - the minimum value of the y-scale
        max - the maximum value of the y-scale
      • clear

        public void clear()
        Clears the screen to the default color (white).
      • clear

        public void clear(java.awt.Color color)
        Clears the screen to the given color.
        Parameters:
        color - the color to make the background
      • getPenRadius

        public double getPenRadius()
        Gets the current pen radius.
        Returns:
        the current pen radius
      • setPenRadius

        public void setPenRadius()
        Sets the pen size to the default (.002).
      • setPenRadius

        public void setPenRadius(double r)
        Sets the radius of the pen to the given size.
        Parameters:
        r - the radius of the pen
        Throws:
        java.lang.IllegalArgumentException - if r is negative
      • getPenColor

        public java.awt.Color getPenColor()
        Gets the current pen color.
        Returns:
        the current pen color
      • setPenColor

        public void setPenColor()
        Sets the pen color to the default color (black).
      • setPenColor

        public void setPenColor(java.awt.Color color)
        Sets the pen color to the given color.
        Parameters:
        color - the color to make the pen
      • setPenColor

        public void setPenColor(int red,
                                int green,
                                int blue)
        Sets the pen color to the given RGB color.
        Parameters:
        red - the amount of red (between 0 and 255)
        green - the amount of green (between 0 and 255)
        blue - the amount of blue (between 0 and 255)
        Throws:
        java.lang.IllegalArgumentException - if the amount of red, green, or blue are outside prescribed range
      • xorOn

        public void xorOn()
        Turns on xor mode.
      • xorOff

        public void xorOff()
        Turns off xor mode.
      • getJLabel

        public javax.swing.JLabel getJLabel()
        Gets the current JLabel for use in some other GUI.
        Returns:
        the current JLabel
      • getFont

        public java.awt.Font getFont()
        Gets the current font.
        Returns:
        the current font
      • setFont

        public void setFont()
        Sets the font to the default font (sans serif, 16 point).
      • setFont

        public void setFont(java.awt.Font font)
        Sets the font to the given value.
        Parameters:
        font - the font
      • line

        public void line(double x0,
                         double y0,
                         double x1,
                         double y1)
        Draws a line from (x0, y0) to (x1, y1).
        Parameters:
        x0 - the x-coordinate of the starting point
        y0 - the y-coordinate of the starting point
        x1 - the x-coordinate of the destination point
        y1 - the y-coordinate of the destination point
      • point

        public void point(double x,
                          double y)
        Draws a point at (x, y).
        Parameters:
        x - the x-coordinate of the point
        y - the y-coordinate of the point
      • circle

        public void circle(double x,
                           double y,
                           double r)
        Draws a circle of radius r, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the circle
        y - the y-coordinate of the center of the circle
        r - the radius of the circle
        Throws:
        java.lang.IllegalArgumentException - if the radius of the circle is negative
      • filledCircle

        public void filledCircle(double x,
                                 double y,
                                 double r)
        Draws a filled circle of radius r, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the circle
        y - the y-coordinate of the center of the circle
        r - the radius of the circle
        Throws:
        java.lang.IllegalArgumentException - if the radius of the circle is negative
      • ellipse

        public void ellipse(double x,
                            double y,
                            double semiMajorAxis,
                            double semiMinorAxis)
        Draws an ellipse with given semimajor and semiminor axes, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the ellipse
        y - the y-coordinate of the center of the ellipse
        semiMajorAxis - is the semimajor axis of the ellipse
        semiMinorAxis - is the semiminor axis of the ellipse
        Throws:
        java.lang.IllegalArgumentException - if either of the axes are negative
      • filledEllipse

        public void filledEllipse(double x,
                                  double y,
                                  double semiMajorAxis,
                                  double semiMinorAxis)
        Draws an ellipse with given semimajor and semiminor axes, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the ellipse
        y - the y-coordinate of the center of the ellipse
        semiMajorAxis - is the semimajor axis of the ellipse
        semiMinorAxis - is the semiminor axis of the ellipse
        Throws:
        java.lang.IllegalArgumentException - if either of the axes are negative
      • arc

        public void arc(double x,
                        double y,
                        double r,
                        double angle1,
                        double angle2)
        Draws an arc of radius r, centered on (x, y), from angle1 to angle2 (in degrees).
        Parameters:
        x - the x-coordinate of the center of the circle
        y - the y-coordinate of the center of the circle
        r - the radius of the circle
        angle1 - the starting angle. 0 would mean an arc beginning at 3 o'clock.
        angle2 - the angle at the end of the arc. For example, if you want a 90 degree arc, then angle2 should be angle1 + 90.
        Throws:
        java.lang.IllegalArgumentException - if the radius of the circle is negative
      • square

        public void square(double x,
                           double y,
                           double r)
        Draws a square of side length 2r, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the square
        y - the y-coordinate of the center of the square
        r - radius is half the length of any side of the square
        Throws:
        java.lang.IllegalArgumentException - if r is negative
      • filledSquare

        public void filledSquare(double x,
                                 double y,
                                 double r)
        Draws a filled square of side length 2r, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the square
        y - the y-coordinate of the center of the square
        r - radius is half the length of any side of the square
        Throws:
        java.lang.IllegalArgumentException - if r is negative
      • rectangle

        public void rectangle(double x,
                              double y,
                              double halfWidth,
                              double halfHeight)
        Draws a rectangle of given half width and half height, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the rectangle
        y - the y-coordinate of the center of the rectangle
        halfWidth - is half the width of the rectangle
        halfHeight - is half the height of the rectangle
        Throws:
        java.lang.IllegalArgumentException - if halfWidth or halfHeight is negative
      • filledRectangle

        public void filledRectangle(double x,
                                    double y,
                                    double halfWidth,
                                    double halfHeight)
        Draws a filled rectangle of given half width and half height, centered on (x, y).
        Parameters:
        x - the x-coordinate of the center of the rectangle
        y - the y-coordinate of the center of the rectangle
        halfWidth - is half the width of the rectangle
        halfHeight - is half the height of the rectangle
        Throws:
        java.lang.IllegalArgumentException - if halfWidth or halfHeight is negative
      • polygon

        public void polygon(double[] x,
                            double[] y)
        Draws a polygon with the given (x[i], y[i]) coordinates.
        Parameters:
        x - an array of all the x-coordindates of the polygon
        y - an array of all the y-coordindates of the polygon
      • filledPolygon

        public void filledPolygon(double[] x,
                                  double[] y)
        Draws a filled polygon with the given (x[i], y[i]) coordinates.
        Parameters:
        x - an array of all the x-coordindates of the polygon
        y - an array of all the y-coordindates of the polygon
      • picture

        public void picture(double x,
                            double y,
                            java.lang.String filename)
        Draws picture (gif, jpg, or png) centered on (x, y).
        Parameters:
        x - the center x-coordinate of the image
        y - the center y-coordinate of the image
        filename - the name of the image/picture, e.g., "ball.gif"
        Throws:
        java.lang.IllegalArgumentException - if the image is corrupt
        java.lang.IllegalArgumentException - if filename is null
      • picture

        public void picture(double x,
                            double y,
                            java.lang.String filename,
                            double degrees)
        Draws picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees.
        Parameters:
        x - the center x-coordinate of the image
        y - the center y-coordinate of the image
        filename - the name of the image/picture, e.g., "ball.gif"
        degrees - is the number of degrees to rotate counterclockwise
        Throws:
        java.lang.IllegalArgumentException - if the image is corrupt
        java.lang.IllegalArgumentException - if filename is null
      • picture

        public void picture(double x,
                            double y,
                            java.lang.String filename,
                            double w,
                            double h)
        Draws picture (gif, jpg, or png) centered on (x, y), rescaled to w-by-h.
        Parameters:
        x - the center x coordinate of the image
        y - the center y coordinate of the image
        filename - the name of the image/picture, e.g., "ball.gif"
        w - the width of the image
        h - the height of the image
        Throws:
        java.lang.IllegalArgumentException - if the image is corrupt
        java.lang.IllegalArgumentException - if filename is null
      • picture

        public void picture(double x,
                            double y,
                            java.lang.String filename,
                            double w,
                            double h,
                            double degrees)
        Draws picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees, rescaled to w-by-h.
        Parameters:
        x - the center x-coordinate of the image
        y - the center y-coordinate of the image
        filename - the name of the image/picture, e.g., "ball.gif"
        w - the width of the image
        h - the height of the image
        degrees - is the number of degrees to rotate counterclockwise
        Throws:
        java.lang.IllegalArgumentException - if the image is corrupt
        java.lang.IllegalArgumentException - if filename is null
      • text

        public void text(double x,
                         double y,
                         java.lang.String s)
        Writes the given text string in the current font, centered on (x, y).
        Parameters:
        x - the center x-coordinate of the text
        y - the center y-coordinate of the text
        s - the text
      • text

        public void text(double x,
                         double y,
                         java.lang.String s,
                         double degrees)
        Writes the given text string in the current font, centered on (x, y) and rotated by the specified number of degrees.
        Parameters:
        x - the center x-coordinate of the text
        y - the center y-coordinate of the text
        s - the text
        degrees - is the number of degrees to rotate counterclockwise
      • textLeft

        public void textLeft(double x,
                             double y,
                             java.lang.String s)
        Writes the given text string in the current font, left-aligned at (x, y).
        Parameters:
        x - the x-coordinate of the text
        y - the y-coordinate of the text
        s - the text
      • show

        @Deprecated
        public void show(int t)
        Deprecated. replaced by enableDoubleBuffering(), show(), and pause(int t)
        Copies the offscreen buffer to the onscreen buffer, pauses for t milliseconds and enables double buffering.
        Parameters:
        t - number of milliseconds
      • pause

        public void pause(int t)
        Pause for t milliseconds. This method is intended to support computer animations.
        Parameters:
        t - number of milliseconds
      • show

        public void show()
        Copies offscreen buffer to onscreen buffer. There is no reason to call this method unless double buffering is enabled.
      • enableDoubleBuffering

        public void enableDoubleBuffering()
        Enable double buffering. All subsequent calls to drawing methods such as line(), circle(), and square() will be deffered until the next call to show(). Useful for animations.
      • disableDoubleBuffering

        public void disableDoubleBuffering()
        Disable double buffering. All subsequent calls to drawing methods such as line(), circle(), and square() will be displayed on screen when called. This is the default.
      • save

        public void save(java.lang.String filename)
        Saves this drawing to a file.
        Parameters:
        filename - the name of the file (with suffix png, jpg, or gif)
      • actionPerformed

        public void actionPerformed(java.awt.event.ActionEvent e)
        This method cannot be called directly.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • addListener

        public void addListener(DrawListener listener)
        Adds a DrawListener to listen to keyboard and mouse events.
        Parameters:
        listener - the {\tt DrawListener} argument
      • isMousePressed

        public boolean isMousePressed()
        Returns true if the mouse is being pressed.
        Returns:
        true if the mouse is being pressed; false otherwise
      • mousePressed

        @Deprecated
        public boolean mousePressed()
        Deprecated. replaced by isMousePressed()
        Returns true if the mouse is being pressed.
        Returns:
        true if the mouse is being pressed; false otherwise
      • mouseX

        public double mouseX()
        Returns the x-coordinate of the mouse.
        Returns:
        the x-coordinate of the mouse
      • mouseY

        public double mouseY()
        Returns the y-coordinate of the mouse.
        Returns:
        the y-coordinate of the mouse
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent e)
        This method cannot be called directly.
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • hasNextKeyTyped

        public boolean hasNextKeyTyped()
        Returns true if the user has typed a key.
        Returns:
        true if the user has typed a key; false otherwise
      • nextKeyTyped

        public char nextKeyTyped()
        The next key typed by the user.
        Returns:
        the next key typed by the user
      • isKeyPressed

        public boolean isKeyPressed(int keycode)
        Returns true if the keycode is being pressed.

        This method takes as an argument the keycode (corresponding to a physical key). It can handle action keys (such as F1 and arrow keys) and modifier keys (such as shift and control). See KeyEvent for a description of key codes.

        Parameters:
        keycode - the keycode to check
        Returns:
        true if keycode is currently being pressed; false otherwise
      • keyTyped

        public void keyTyped(java.awt.event.KeyEvent e)
        This method cannot be called directly.
        Specified by:
        keyTyped in interface java.awt.event.KeyListener
      • keyPressed

        public void keyPressed(java.awt.event.KeyEvent e)
        This method cannot be called directly.
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
      • keyReleased

        public void keyReleased(java.awt.event.KeyEvent e)
        This method cannot be called directly.
        Specified by:
        keyReleased in interface java.awt.event.KeyListener
      • main

        public static void main(java.lang.String[] args)
        Test client.
        Parameters:
        args - the command-line arguments

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.