EventTextField
Class Diagram
Ancestor class specifications:
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
EventTextField
Class Specification
Invariant
An EventTextField 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).)
- the outer dimensions of the text field are given by width and height.
- if necessary, the text field image is clipped to the boundaries of its GUI container.
- when it is contained within a proper GUI container the text field contains user-editable text.
Constructor Methods
public EventTextField( )
post: A new EventTextField object is created
and text == ""
and x == 0 and y == 0
and width == 0 and height == 0
(Note that EventTextFields 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 text field is added to a Container
implies result ==
the Container to
which this is added
and this text field is not added implies result ==
null
public String getText( )
post: result == text
note: The user can supply input by editing text
Event Handler Method
public abstract void actionPerformed( java.awt.event.ActionEvent e )
note: This method is called whenever the return key is struck within this text field. The e parameter passes an associated event object. The class inheriting EventTextField must override this method.