Step 1 creates several user interface components and adds them to the applet's inherent panel. Components include a
TextArea
and aButton
.Use of these components is illustrated in the applet that follows.
Example Applet
import java.applet.Applet; import java.awt.*; public class step1 extends Applet{ // adds UI components TextArea ta = new TextArea ("My Text Area", 5, 40); Button button = new Button ("Button"); public void init ( ){ setBackground (Color.white); setForeground (Color.red); add (ta); add (button); } // end init }// end step1Run the applet
Discussion
As can be seen in the class hierarchy, most UI components are subclasses of
Component
; their declaration is straight-forward. They are added to the applet's inherent panel through theadd
method, which is included in theContainer
class. Thus, messages propagate up the hierarchy from the applet toPanel
toContainer
.Question: in what class are the two methods that set colors found?