2 réponses
Ces valeurs "item 1", "item 2" etc. ne sont pas apparues par hasard, elles sont forcément dans le code source, tu peux donc mettre ce que tu veux à la place.
Exemple de base d'utilisation d'un JComboBox :
import javax.swing.JComboBox;
public class TestFrame extends JFrame {
private static final long serialVersionUID = 1;
public static void main(String[] args) {
new TestFrame();
}
public TestFrame() {
String[] jours = { "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi",
"Samedi", "Dimanche" };
add(new JComboBox<String>(new DefaultComboBoxModel<String>(jours)));
setBounds(100, 100, 100, 75);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public class Saisie extends javax.swing.JFrame {
public Saisie() {
initComponents();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
}
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}