View RSS Feed

Java AWT

Drawing a Point

Rate this Entry
by , 03-06-2012 at 08:45 PM (490 Views)
Point class creates location presenting x,y coordinate space. Point class consist of these sub classes.

  • Point2D.Float
  • Point2D.Double

Double precision and float are provided by these given classes to store the point’s coordinates, respectively.
Java Code:
//Create Point2D.Double
Point2D.Double point = new Point2D.Double(x, y);
For creation of coordinate along with 0,0, default constructor Point 2D.Double can be used.
Point’s position is being set by using method setLocation, as it is given below.

  • setLocation(double x, double y) –For setting the point defining coordinates location as double values.
  • setLocation(Point2D p) –Coordinates of other point are used for setting up the point’s location.

These methods are supported by the point2D.

  • Distance b/w point with coordinates & current point is calculated.
  • Distance b/w 2 points are calculated.

Submit "Drawing a Point" to Facebook Submit "Drawing a Point" to Digg Submit "Drawing a Point" to Submit "Drawing a Point" to StumbleUpon Submit "Drawing a Point" to Google