Code:
// java tutorial 68 JRadioButton
// Java tutorial 67 final JRadioButton
// Java tutorial 69 Drop down list program
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BT68Gui extends JFrame{
private JComboBox box;
private JLabel picture;
private static String[] filename = {"b.png, x.png"};// and Array with two elements this Array stores the filename
private Icon[] pics = {new ImageIcon(getClass().getResource(filename[0])), new ImageIcon(getClass().getResource(filename[1]))}; // This Array stores the pictures filename 0 is the first element of the Aray
public BT68Gui(){
super("The Title");
setLayout(new FlowLayout());
box = new JComboBox(filename);
box.addItemListener(
new ItemListener(){
public void itemStateChanged(ItemEvent event){ od
if(event.getStateChange()==ItemEvent.SELECTED)
picture.setIcon(pics[box.getSelectedIndex()]);/
}
}
}; //compiler shows error
add(box); // compiler shows error
picture = new JLabel(pics[0]);
add(picture);
}
}

