Friday, 31 August 2012

Combo Box Deministration


    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    /*<applet code = choice.java width=200 height=200></applet> */
  
   public class choice extends Applet implements ItemListener
   {
            Choice lang,db;
            String msg=" ";
            public void init()
            {
                        lang=new Choice();
                        db=new Choice();

                        /*adding items to language*/
                        lang.add("c");
                        lang.add("c++");
                        lang.add("vb");
                        lang.add("vc++");
                        lang.add("java");

                        /*adding to database*/
                        db.add("oracle 8i");
                        db.add("oracle 9i");
                        db.add("ms-Access");
                       
                        add(lang);
                        add(db);
                       
                        lang.addItemListener(this);
                        db.addItemListener(this);
            }
            public void itemStateChanged (ItemEvent e)
            {
                 repaint();
            }
   
public void paint(Graphics g)
            {
                        msg="CURRENT SELECTED LANGUAGE: ";
                       

msg+=lang.getSelectedItem();
                        g.drawString(msg,6,40);
                        msg="CURRENT SELECTED DATABASE: ";
                        msg+=db.getSelectedItem();
                        g.drawString(msg,16,160);
            }
 }




No comments:

Post a Comment