Citation:
public class Ville extends JFrame implements ActionListener {
private JPanel container = null ; //Déclaration de l’objet JPanel
private FlowLayout layout = null ; //Déclaration de notre layout
private JLabel ChoixRegion = null ;
private JLabel ChoixVille = null ;
private JComboBox ListeRegion = null ;
private Object[] Region = new Object[] {"Alsace","Bouches-du-Rhone"};
private JComboBox ListeVille = null ;
private Object[] Ville = new Object[] {"Aix","Colmar","Marseille","Strasbourg"};
/** Creates a new instance of FenetreAvecTexte */
public Ville() {
super() ;
build() ;
}
private void build(){
this.setContentPane(getContainer());
this.setTitle("Choix de la ville");
this.setSize(275,200);
this.setLocationRelativeTo(null);
this.setResizable(false) ;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
Ville gui = new Ville();
gui.setVisible(true);
}
private JPanel getContainer(){
layout = new FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
container = new JPanel() ;
container.setLayout(layout);
ChoixRegion = new JLabel("Choisissez la région");
ChoixRegion.setPreferredSize(new Dimension(200,25));
container.add(ChoixRegion);
ListeRegion = new JComboBox(Region) ;
ListeRegion.setPreferredSize (new Dimension(100,25)) ;
container.add(ListeRegion) ;
ChoixVille = new JLabel("Choisissez la ville");
ChoixVille.setPreferredSize(new Dimension(200,25));
container.add(ChoixVille);
ListeVille = new JComboBox(Ville) ;
ListeVille.setPreferredSize (new Dimension(100,25)) ;
container.add(ListeVille) ;
return container ;
}
public void actionPerformed(ActionEvent e) {
}
}