Label Class Diagram

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Ancestor class specifications:

java.lang.Object
java.awt.Component


Label Class Specification

            Invariant

                        A Label object...

-       is a string of text.

-       should be added to a container object with its upper-left corner x pixels from the left and y pixels from the top. (The upper left corner of the container is (0, 0).)

-       when it is contained within a proper GUI container the value of text is displayed in color foreColor in a rectangular region; this region has a background color of backColor.

 

Below is a Label with text == "message", a white backColor and a black foreColor.

Constructor Methods

public Label( String s )

post: A new Label object is created

         and   text == s

         and   foreColor == Color.black   and   backColor is transparent

         (Note that Labels don't appear until added.)

 

            Update Methods

public void setBackground( java.awt.Color c )

post:  backColor == c

 

public void setForeground (java.awt.Color c )

post:  foreColor == c

 

public void setBounds( int initX,  int initY,  int w,  int h)

post: x == initX   and   y == initY

         and   width == w    and   height == h

 

public void setText( String s )

post: text == s

 

public void repaint( )

post:  Causes the Java virtual machine to update the display of this object as soon as possible.

 

            Query Methods

public java.awt.Color  getBackground( )

post:  result == backColor

 

public java.awt.Color  getForeground( )

post:  result == foreColor

 

public int getX( )

post:  result == x

 

public int getY( )

post:  result == y

 

public int getWidth( )

post:  result == width

 

public int getHeight( )

post:  result == height

 

publicString getText( )

post:  result == text