Tweet
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code = "JComboBoxDemo" width=300 height =100>
</applet>
*/
public class JComboBoxDemo extends JApplet implements ItemListener
{
JLabel j1;
ImageIcon india,australia,pakistan,bangladesh,england,spain;
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBox jc=new JComboBox();
jc.addItem("India");
jc.addItem("Australia");
jc.addItem("Pakistan");
jc.addItem("Bangladesh");
jc.addItem("England");
jc.addItem("Spain");
jc.addItemListener(this);
contentPane.add(jc);
j1=new JLabel(new ImageIcon("india.gif"));
contentPane.add(j1);
}
public void itemStateChanged(ItemEvent ie)
{
String s=(String)ie.getItem();
j1.setIcon(new ImageIcon(s+ ".gif"));
}
}
Java JComboBox using applet
Posted by
LAHAUL SETH
~
Java JComboBox using applet
2012-01-06T09:14:00+05:30
LAHAUL SETH
Java
|
Java Applet
|
Comments
Java JComboBox using applet
2012-01-06T09:14:00+05:30
LAHAUL SETH
Java
|
Java Applet
|