title: Implementing ItemListener
body: <p>i've been having problem in the itemStateChanged section. when I compiled the program i get the "cannot find variable" error and I can't seem to find out where I did wrong. Any help is much appreciated. Thank You.</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class Postcode extends JFrame implements ItemListener {
  
      public static void main(String[] arg) {
          JFrame fr = new JFrame("Melaka Postcode");
          fr.setSize(240, 125);
          fr.setVisible(true);
          fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  
      public Postcode() {
          String[] code = {"75450", "77000", "78000"};
          JLabel lb1 = new JLabel("Postcode");
          JLabel lb2 = new JLabel("District?");
          JPanel p1 = new JPanel();
          JPanel p2 = new JPanel();
          JComboBox cb = new JComboBox(code);
          cb.addItemListener(this);
          Font f = new Font("Verdana", Font.BOLD, 14);
          lb2.setFont(f);
          p1.add(lb1);
          p1.add(cb);
          p2.add(lb2);
      }
  
      public void itemStateChanged(ItemEvent e) {
          if (code.getSelectedItem().equals("75450")) {
              lb2.setText = "Bukit Beruang";
          }
          if (code.getSelectedItem().equals("77000")) {
              lb2.setText = "Jasin";
          }
          if (code.getSelectedItem().equals("75450")) {
              lb2.setText = "Alor Gajah";
          }
      }
  }
  </code></pre>