السلام عليكم ورحمة الله ولركاته
عندي مشكلة في اضافة عناصر ل ComboBox
حسب اضافة note
أي كلما اضف client
يضاف اسمه في comboBox
المحاولة في الكود المرفق
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DialogueEtiquette extends JDialog implements ActionListener {
private JTextField champDeTexte;
public JComboBox jComboBox1;
DialogueEtiquette(String titre) {
super((JFrame) null, titre, true);
JLabel jLabel1=new JLabel("Le nom de client");
getContentPane().add(jLabel1);
jLabel1.setBounds(10, 30, 130, 14);
JButton bouton = new JButton("OK");
getContentPane().add(bouton);
bouton.setBounds(230, 60, 60, 23);
bouton.addActionListener(this);
champDeTexte = new JTextField(20);
getContentPane().add(champDeTexte);
champDeTexte.setBounds(135, 30, 160, 20);
champDeTexte.addActionListener(this);
jComboBox1 = new JComboBox();
jComboBox1.setBounds(135, 60, 70, 20);
jComboBox1.addActionListener(this);
getContentPane().add(jComboBox1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 332, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 129, Short.MAX_VALUE)
);
getContentPane().setBounds(100, 20, 300, 300);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
.getScreenSize();
setLocation((screenSize.width-getSize().width)/2,(screenSize.height-getSize().height)/2);
setVisible(true);
}
public String getText() {
return champDeTexte.getText();
}
public String getItm() {
return (String)jComboBox1.getSelectedItem();
}
public void actionPerformed(ActionEvent evt) {
dispose();
}
}كود 2
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DialogueEtiquetteS extends JDialog implements ActionListener {
private JTextField champDeTexte;
DialogueEtiquetteS(String titre) {
super((JFrame) null, titre, true);
JLabel jLabel1=new JLabel("La note:");
getContentPane().add(jLabel1);
jLabel1.setBounds(10, 30, 70, 14);
champDeTexte = new JTextField(20);
getContentPane().add(champDeTexte);
champDeTexte.setBounds(80, 30, 230, 20);
JButton bouton = new JButton("OK");
getContentPane().add(bouton);
bouton.setBounds(250, 60, 60, 23);
bouton.addActionListener(this);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 332, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 129, Short.MAX_VALUE)
);
getContentPane().setBounds(100, 20, 300, 300);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
.getScreenSize();
setLocation((screenSize.width-getSize().width)/2,(screenSize.height-getSize().height)/2);
setVisible(true);
}
public String getText() {
return champDeTexte.getText();
}
public void actionPerformed(ActionEvent evt) {
dispose();
}
}الصوى المرفقة
شكرااااااااااااااااااا
