Choices:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="ChoiceDemo" width=300 height=300></applet>*/
public class ChoiceDemo extends Applet implements ItemListener
{
Label l1;
public void init()
{
Choice c1=new Choice();
c1.addItem("Red");
c1.addItem("Green");
c1.addItem("Blue");
c1.addItem("Yellow");
c1.addItem("Orange");
c1.addItem("Gray");
c1.addItem("Pink");
c1.addItemListener(this);
add(c1);
}
public void itemStateChanged(ItemEvent ie)
{
Choice c=(Choice)ie.getItemSelectable();
String s=c.getSelectedItem();
if(s.equals("Red"))
setBackground(Color.red);
else if(s.equals("Green"))
setBackground(Color.green);
else if(s.equals("Blue"))
setBackground(Color.blue);
else if(s.equals("Yellow"))
setBackground(Color.yellow);
else if(s.equals("Orange"))
setBackground(Color.orange);
else if(s.equals("Gray"))
setBackground(Color.gray);
else if(s.equals("Pink"))
setBackground(Color.pink);
}
}
A servlet is a java class that extends an application hosted on a web server. Handles the HTTP request-response process (for our purposes) Often thought of as an applet that runs on a server. Provides a component base architecture for web development, using the Java Platform The foundation for Java Server Pages (JSP). Alternative to CGI scripting and platform specific server side applications.
Comments
Post a Comment