2 réponses
KX
Messages postés
16734
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
24 avril 2024
3 015
18 juil. 2013 à 18:36
18 juil. 2013 à 18:36
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.
KX
Messages postés
16734
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
24 avril 2024
3 015
18 juil. 2013 à 19:15
18 juil. 2013 à 19:15
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); } }
18 juil. 2013 à 18:48
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
}
18 juil. 2013 à 19:06