1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
   |  
import  javax.swing.*;
 
import  java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
 
public class Form1 extends JFrame  implements ActionListener 
{
     public  Form1()
    {   
        super("Fenêtre 1");             
        setBounds(300,100,350,500); 
 
        JPanel Panel11=new JPanel(); //créer un panel
 
        JLabel Combo1 =new JLabel("Type:");
        Panel11.add(Combo1,BorderLayout.WEST);
        String  c1[] ={"1","2","3","4","5"}; //contenu de la comboBox
        JComboBox list_Typ_Elt=new JComboBox(c1);
 
        Panel11.add(list_Typ_Elt,BorderLayout.WEST);
 
 
       Combo1.addActionListener(new ActionListener() 
        	      { public void actionPerformed(ActionEvent e)
        	       { 
        	          JComboBox cb = (JComboBox)e.getSource();
        	   //code sur sélection de la combo
        	       }}
        	       );
 
 
    }    
 
	    public  static void  main(String args[])
	    {
	        new Form1();
	    }
 
} | 
Partager