Comment programmer jcombobox ???

Bonjour,
Bonsoir ,j'ai une jcombobox avec les différents langues et je voudrais changer l langue des interface ,mais j n'y arrive pas ;(
merci d'avance .
Configuration: Windows Vista
Safari 532.5

2 réponses

  • Votes
  • Date
  • Date décroissante
  1. si ce code peut résoudre ton problème :

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;

    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;

    public class Fenetre extends JFrame {

    private JPanel container = new JPanel();
    private JComboBox combo = new JComboBox();
    private JLabel label = new JLabel("Une ComboBox");

    public Fenetre(){

    this.setTitle("Animation");
    this.setSize(300, 300);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLocationRelativeTo(null);

    container.setBackground(Color.white);
    container.setLayout(new BorderLayout());

    combo.setPreferredSize(new Dimension(100,20));
    combo.addItem("Option 1");
    combo.addItem("Option 2");
    combo.addItem("Option 3");
    combo.addItem("Option 4");

    JPanel top = new JPanel();
    top.add(label);
    top.add(combo);

    container.add(top, BorderLayout.NORTH);
    this.setContentPane(container);
    this.setVisible(true);
    }
    }
    1. alors qu'il te faut un vecteur pour les listes dynamiques

      par exemple :

      import java.util.Vector;

      import javax.swing.JComboBox;
      import javax.swing.JFrame;

      public class MainClass extends JFrame {
      MainClass(String title) {
      super(title);

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      Vector v = new Vector();
      v.add("A");
      v.add("B");
      v.add("C");
      JComboBox jcb = new JComboBox(v);

      getContentPane().add(jcb);

      setSize(200, 50);
      setVisible(true);
      }

      public static void main(String[] args) {
      new MainClass("Combo box Demo1");
      }
      }