// Change the various images using List
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ima4 extends Applet implements ItemListener
{
List l;
Image i1,i2,i3,i4;
TextArea ta;
public void init()
{
i1 = getImage(getCodeBase(),"ro1.jpg");
i2 = getImage(getCodeBase(),"su1.jpg");
i3 = getImage(getCodeBase(),"lo1.jpg");
l=new List();
l.add("Rose");
l.add("SunFlower");
l.add("Lotus");
add(l);
l.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
repaint();
}
public void paint(Graphics g)
{
if(l.getSelectedItem()=="Rose")
{
g.drawImage(i1,80,100,this);
}
if(l.getSelectedItem()=="SunFlower")
{
g.drawImage(i2,80,100,this);
}
if(l.getSelectedItem()=="Lotus")
{
g.drawImage(i3,80,100,this);
}
}
}
/* <body>
<applet code = "ima4.class" height = 350 width = 350>
</applet>
</body> */Java
Java Applet - Changing the various Flowers using List Component.

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
