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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
| import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Fenetre extends JFrame implements ActionListener
{
private JComboBox ch1, ch2, ch3, ch4, ch21, ch22;
private JTextField a1, a2;
private JButton b_calcul, b_modification, b_validation, b_quitte;
private JTextField resultat;
public Fenetre()
{
setTitle("BIENVENUE SUR MON SITE D'ACHAT DE COURSE EN LIGNE");
Container ccf = this.getContentPane();
GridLayout g = new GridLayout(19,10);
ccf.setLayout(g);
JPanel p1 = new JPanel();
p1.add(new JLabel("Etes-vous déjà client ? Faites votre choix en cliquant sur la flèche"));
ch1 = new JComboBox();
ch1.addItem(" ");
ch1.addItem("OUI");
ch1.addItem("NON");
p1.add(ch1);
ccf.add(p1);
JPanel p2 = new JPanel();
p2.add(new JLabel("Faites votre choix de produits en cliquant sur la flèche"));
ch2 = new JComboBox();
ch2.addItem(" ");
ch2.addItem("article1 prix unité = 30 euros : nombre ");
ch2.addItem("article2 prix unité = 40 euros : nombre ");
p2.add(ch2);
ccf.add(p2);
JPanel p3 = new JPanel();
p3.add(new JLabel("Quel est le solde de votre carte U ?"));
ch3 = new JComboBox();
ch3.addItem(" ");
p3.add(ch3);
ccf.add(p3);
JPanel p4 = new JPanel();
p4.add(new JLabel("Choisissez le jour de livraison et le créneau horaire"));
ch4 = new JComboBox();
ch4.addItem(" ");
ch4.addItem("lundi 11h30-14h");
ch4.addItem("lundi 17h-20h30");
ch4.addItem("mardi 11h30-14h");
ch4.addItem("mardi 17h-20h30");
ch4.addItem("mercredi 11h30-14h");
ch4.addItem("mercredi 17h-20h30");
ch4.addItem("jeudi 11h30-14h");
ch4.addItem("jeudi 17h-20h30");
ch4.addItem("vendredi 11h30-14h");
ch4.addItem("vendredi 17h-20h30");
ch4.addItem("samedi 11h30-14h");
ch4.addItem("samedi 17h-20h30");
p4.add(ch4);
ccf.add(p4);
JPanel p21 = new JPanel();
p21.add(new JLabel("article2 prix unité = 30 euros : nombre "));
ch21 = new JComboBox();
ch21.addItem("0");
ch21.addItem("1");
ch21.addItem("2");
ch21.addItem("3");
ch21.addItem("4");
ch21.addItem("5");
p21.add(ch21);
p21.add(new JLabel(" total = "));
a1 = new JTextField("0",2);
p21.add(a1);
ccf.add(p21);
JPanel p22 = new JPanel();
p22.add(new JLabel("article1 prix unité = 40 euros : nombre "));
ch22 = new JComboBox();
ch22.addItem("0");
ch22.addItem("1");
ch22.addItem("2");
ch22.addItem("3");
ch22.addItem("4");
ch22.addItem("5");
p22.add(ch22);
p22.add(new JLabel(" total = "));
a2 = new JTextField("0",2);
p22.add(a2);
ccf.add(p22);
JPanel p5 = new JPanel();
p5.setLayout(new FlowLayout(FlowLayout.RIGHT));
b_calcul = new JButton(" CALCUL du TOTAL du panier ");
p5.add(b_calcul);
p5.add(new JLabel (" TOTAL à payer = "));
resultat = new JTextField("0",3);
p5.add(resultat);
ccf.add(p5);
JPanel p6 = new JPanel();
p6.setLayout(new FlowLayout(FlowLayout.CENTER));
b_modification = new JButton(" MODIFICATION DE LA COMMANDE ");
p6.add(b_modification);
ccf.add(p6);
b_calcul.addActionListener(this);
b_modification.addActionListener(new Delegue());
JPanel p7 = new JPanel();
p7.setLayout(new FlowLayout(FlowLayout.CENTER));
b_validation = new JButton(" VALIDATION DE LA COMMANDE ");
p7.add(b_validation);
ccf.add(p7);
b_calcul.addActionListener(this);
b_validation.addActionListener(new Delegue());
JPanel p8 = new JPanel();
p8.setLayout(new FlowLayout(FlowLayout.CENTER));
b_quitte = new JButton(" QUITTER sans commander");
p8.add(b_quitte);
ccf.add(p8);
b_quitte.addActionListener(new Delegue());
}
public void actionPerformed(ActionEvent e)
{
int num1 = ch2.getSelectedIndex();
int val2 = 30*(num1);
String rr2 = Integer.toString(val2);
a1.setText(rr2);
int num2 = ch3.getSelectedIndex();
int val3 = 40*(num2);
String rr3 = Integer.toString(val3);
a2.setText(rr3);
String rrr = Integer.toString(val2+val3);
resultat.setText(rrr);
}
}
class Delegue implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
public class Site1
{
public static void main (String args[])
{
Fenetre f1 = new Fenetre();
f1.pack();
f1.setVisible(true);
}
} |
Partager