Simple Applet Display Method
AWT :
The AWT make use of the
Container class which is the super base class for all the classes of the
package java.awt. Basically it provides the method add() to add the component
on the applet
The general form will be
add(object);
If we add the component to
the applet window then only it can be we visible on the applet.
Simple Applet
Display Method:
setBackground(Color.newColor);
setForeground(Color.
newColor);
A good place to set the
Foreground and Background color in the init() method. The setBackground is used
to set Background color of applet. And Foreground is used for set the text
color on the applet.
PROGRAM-2
import java.applet.*;
import java.awt.*;
/*
<applet code="Appcolor"
height=200 width=200>
</applet>
*/
public class Appcolor extends
Applet
{ String
a;
public
void init()
{
setBackground(Color.BLUE);
setForeground(Color.red);
Label
l1=new Label("BMB", Label.RIGHT);
add(l1);
a="hiiiiiiiiiiiiiiiii
BMB";
}
public
void Paint(Graphics g)
{
g.drawString(a,10,40);
}
}
Comments
Post a Comment