Drawing Shapes:

  1. To draw shapes on a Graphics2S object, invoke the draw(Shape s) instance method.

    To find out more on the draw(Shape s) method, see doc for java.awt.Graphics2D: click here

    For details on Shapes, see doc for java.awt.Shape: click here

  2. Circles and Ovals:

  3. Inner classes:


    Example of an inner class:
       public class myClass
        {
          ...variables...
          ...methods...
    
          public class anotherClass  // <-- inner class
           {
    	 ...inner class' variables
    	 ...inner class' methods
    	 ...inner class can also have inner classes...
           }
        }
    

    For now, just think of an inner class as a class with a longer name - detail much much later...

    BUT: you must only import the outer class:

                                                                import java.awt.geom.Ellipse;

  4. Points: java.awt.goem.Point2D click here

    Example: creating two Point objects p1 & p2
          Points2D.Double p1 = new Points2D.Double(x1, y1);
          Points2D.Double p2 = new Points2D.Double(x2, y2);
    

    NOTE: another inner class

  5. Lines: java.awt.goem.Line2D click here

    Example: creating a Line objects "segment"

    First, define the end points of the line:

          Points2D.Double p1 = new Points2D.Double(x1, y1);
          Points2D.Double p2 = new Points2D.Double(x2, y2);
    
    Then, define the line segment using the points p1 and p2:
          Line2D.Double segment = new Line2D.Double(p1, p2);
    

    You can also create a line object using 4 double values:

    Example:
          Line2D.Double segment = new Points2D.Double(x1, y1, x2, y2);
    
    Question: How is this done ?