Monday, 15 October 2012

java Combo Box

 
//JComboBox Demo
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 jl;
ImageIcon Flowers, Koala, Desert, Penguins, sateesh;

public void init(){
// Get content pane
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());

// Create a Combo box and add it
//to the pane
JComboBox jc = new JComboBox();
jc.addItem("Flowers");
jc.addItem("Koala");
jc.addItem("Desert");
jc.addItem("Penguins");
jc.addItem("sateesh");
jc.addItemListener(this);
contentPane.add(jc);

//Create label
jl = new JLabel(new ImageIcon("Flowers.gif"));
contentPane.add(jl);
}

public void itemStateChanged(ItemEvent ie) {
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s +".gif"));
}
}

1 comment:

Anonymous said...

Its like you learn my thoughts! You sеem to grasp so much apprохimаtely this, such as yοu
ωrote thе e-book іn іt or somеthing.
I think that you juѕt can do wіth some % to power the message house a bit, however other than that, this is magnificent blog. A fantastic read. I'll definitely be back.

Also visit my homepage; ardms ultrasound technologist