EventButton
Class Diagram
Ancestor class specifications:
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
EventButton
Class Specification
Invariant
An EventButton object...
- is drawn as a rectangular solid.
- 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 button contains text and the dimensions are given by width and height.
- if necessary, the button image is clipped to the boundaries of its GUI container.
Constructor Methods
public EventButton( String s )
post: A new EventButton object is created
and text == s
and x == 0 and y == 0
and width == 0 and height == 0
(Note that EventButtons don't appear until added.)
Update Methods
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 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 setText( String s )
post: text == s
Query Methods
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 button is added to a Container
implies result ==
the Container to
which this is added
and this button is not added implies result ==
null
publicString getText( )
post: result == text
Event Handler Method
public abstract void actionPerformed( java.awt.event.ActionEvent e )
note: This method is called whenever this button is clicked. The e parameter passes an associated event object. The class inheriting EventButton must override this method.