------------------------------------------------------------------------ Summary information for the Easy Components ------------------------------------------------------------------------ Summary of EasyComponents A component is a graphical entity that is part of a graphical user interface. The components we will study are frames, panels, textfields, textareas, labels, buttons, and timers. The “E” is for “easier”. Quick Reference (an abstract class can only be extended, not created by “new” because one or more methods must be completed) EFrame – the outside container that holds all other components, your class should extend this class. EPanel – a container to hold components that should be grouped together (may create using new) EField – a one line space for user to enter text, you create private inner classes by extending this class (EField is abstract). ETextArea – a multi-line space for text (create by using new) ELabel – a place for information set by your program (create by using new) EButton – a button that responses to clicking, causing some action to be performed, your buttons should extend this class (EButton is abstract.) ETimer – a timer that controls animation or interaction pacing, create an inner class for each timer (ETimer is abstract) EFrame – is a rectangular window that appears on the screen. A subclass of EFrame must have a constructor that adds components (buttons, textfields, pictures, etc.) as desired. Always finish by saying setVisible(true); this final command is what makes the frame appear on the screen. The key method for EFrames is add(someComponent); it is used in this constructor EField – A subclass of EField is generally defined inside the EFrame subclass. It needs nothing more than one method: onEnter() will execute when the user presses the ENTER key within the textfield. You can set the width of an EField, measured in characters, with the instance method width(numCharacters) ETextArea – An ETextArea object displays a large amount of textual information. You will also have scroll bars on this area, so the user can scroll up-and-down or left-and-right to read all the material printed there. You add one line to the information displayed in an ETextArea by using et.say(messageString). ELabel – You create an ELabel object using new ELabel(). You can place a picture at that spot on the screen using the ELabel instance method picture(fileString). It returns the ELabel object itself, so it can be used within thisEFrame.add(someComponent). EButton – A subclass of EButton is generally defined inside the EFrame subclass. It needs nothing more than one method: onClick() will execute when the user clicks the button. ETimer – A subclass of ETimer is generally defined inside the EFrame subclass. It must have an onBeep() instance method. You use the instance method delay(m), which returns the ETimer itself, to tell the timer to wait for a period of m milliseconds (1000 milliseconds is 1 second) before executing its onBeep method. ETimer is a subclass of ELabel, because an ETimer is often used to display a picture that changes frequently, once each time onBeep is called. You can stop the beeping with the ETimer instance method stop(). Summary of E-object classes, constructors and methods EFrame subclass can use super() or super(titleString, widthInt,heightInt, isMainBoolean); eo.add (someComponent) // insert the component in the frame, book-reading order eo.setVisible (true) // makes the frame appear on the screen eo.startNewRow() // start a new row for components being added eo.dispose() // close the frame new ELabel() eo.picture (fileString) // place the picture on the label; return the ELabel itself eo.getPicture() returns String // find out which picture is on it ("" if none) eo.text (titleString) // place the text on the label; return the ELabel itself eo.setText (titleString) // change what the label says on it eo.getText() returns String // find out what the label says on it new ETextArea (heightOfTextAreaInCharacters, widthOfTextAreaInCharacters) eo.say (stringAppended) // add this string as the next line in the textarea EButton subclass can use super(); it must define method onClick() to react to a click eo.text (titleString) // place the text on the button; return the EButton itself eo.setText (titleString) // change what the button says on it eo.getText() returns String // find out what the button says on it EField subclass can use super(); it must define method onEnter() to react to ENTER key eo.width (numCharacters) // make it many characters wide; return the EField itself eo.text (titleString) // place the text in the textfield; return the EField itself eo.setText (titleString) // change what the textfield says in it eo.getText() returns String // find out what the textfield says in it ETimer subclass can use super(); it must define method onBeep() [subclass of ELabel] eo.delay (millisecondsInt) // execute onBeep() after a delay; return the ETimer itself eo.stop() // terminate the timer, so onBeep() will not be executed