Oval
Class Diagram
Ancestor class specifications:
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
Oval
Class Specification
Invariant
An Oval object...
- is drawn as an elliptical solid.
- should be added to a container object with its leftmost point x pixels from the left and its top y pixels from the container top. (The upper left corner of the container is (0, 0).)
- when it is contained within a proper GUI container the oval appears in color color and the dimensions of the oval are given by width and height.
- if necessary, the oval image is clipped to the boundaries of its GUI container.
Below is
a black Oval added to
My Window.

Constructor Methods
public Oval( int initX, int initY, int w, int h )
post: A new Oval object is created
and color == Color.black
and x == initX and y == initY
and width == w and height == h
(Note that Ovals don't appear until added.)
Update
Methods
public void setBackground( java.awt.Color c )
post: color == c
public void setLocation( int intX, int initY )
post: x == initX and y ==
initY
public void setSize( int w, int h )
post: width == w and height == h
public void repaint( )
post: Causes the Java virtual machine to update the display of this object as soon as possible.
public void add( java.awt.Component pic, int j )
pre: j == 0 for best results
post: The pic graphical object will be drawn upon this Oval
Query
Methods
public java.awt.Color getBackground( )
post: color == c
public int getX( )
post: result == x
public int getY( )
post: result == y
public int getWidth( )
post: result == width
public int getHeight( )
post: result == height
public java.awt.Container getParent( )
post: this Oval is added to a Container
implies result ==
the Container to
which this is added
and this Oval is not added implies result == null