1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| import DAO.Achat;
import DAO.AchatDAO;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class ZDialog extends JDialog {
private ZDialogInfo zInfo = new ZDialogInfo();
private JLabel referenceLabel, quantiteLabel;
private JTextField quantite;
private JComboBox reference;
public ZDialog(JFrame parent, String title, boolean modal) {
super(parent, title, modal);
this.setSize(600, 150);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
this.initComponent();
}
public ZDialogInfo showZDialog() {
this.setVisible(true);
return this.zInfo;
}
private void initComponent() {
JPanel panReference = new JPanel();
panReference.setBackground(Color.white);
panReference.setPreferredSize(new Dimension(220, 60));
panReference.setBorder(BorderFactory.createTitledBorder("Référence de la cartouche"));
reference = new JComboBox();
AchatDAO achatDAO = new AchatDAO();
Achat a = new Achat();
achatDAO.showReference(a);
/*reference.addItem("Masculin");
reference.addItem("Féminin");
reference.addItem("Indéterminé");*/
referenceLabel = new JLabel("Référence : ");
panReference.add(referenceLabel);
panReference.add(reference);
JPanel panQuantite = new JPanel();
panQuantite.setBackground(Color.white);
panQuantite.setPreferredSize(new Dimension(220, 60));
panQuantite.setBorder(BorderFactory.createTitledBorder("Quantité d'achat"));
quantiteLabel = new JLabel("Quantité : ");
quantite = new JTextField("1");
quantite.setPreferredSize(new Dimension(90, 25));
panQuantite.add(quantiteLabel);
panQuantite.add(quantite);
JPanel content = new JPanel();
content.setBackground(Color.white);
content.add(panReference);
content.add(panQuantite);
JPanel control = new JPanel();
JButton okBouton = new JButton("OK");
okBouton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
zInfo = new ZDialogInfo((String)reference.getSelectedItem(), quantite.getText());
setVisible(false);
}
});
JButton cancelBouton = new JButton("Annuler");
cancelBouton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
}
});
control.add(okBouton);
control.add(cancelBouton);
this.getContentPane().add(content, BorderLayout.CENTER);
this.getContentPane().add(control, BorderLayout.SOUTH);
}
} |
Partager