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
| package projet.interfaceGraphique;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import projet.dm2Class.*;
public class Ecran extends JPanel {
private JPanel pan1;
private JPanel pan2;
private JPanel panForm;
public JPanel panInfo;
public JButton bouton;
public JTextArea info;
private JLabel lab1;
private JLabel lab2;
private JTextField borne;
private JTextField tps;
public JButton insertion;
private boolean retirerCarte = false;
private TypeRecharge rechargeRapide = new TypeRecharge("R");
private Carte carte25 = new Carte("Po", "Lem", 25, rechargeRapide);
public Ecran() {
this.setLayout(new BorderLayout());
JPanel panForm = new JPanel();
JLabel lab1 = new JLabel("Veuillez choisir votre borne :");
JTextField borne = new JTextField(" ");
JPanel pan1 = new JPanel();
pan1.setLayout(new BorderLayout());
pan1.add(lab1, BorderLayout.WEST);
pan1.add(borne, BorderLayout.EAST);
pan1.setBackground(Color.ORANGE); //Définition de sa couleur de fond
JLabel lab2 = new JLabel("Choisissez un temps de rechargement en secondes :");
JTextField tps = new JTextField(" ");
JPanel pan2 = new JPanel();
pan2.setLayout(new BorderLayout());
pan2.add(lab2, BorderLayout.WEST);
pan2.add(tps, BorderLayout.EAST);
pan2.setBackground(Color.ORANGE); //Définition de sa couleur de fond
//Ajout de l'adaptateur au bouton :
MouseAdapter adaptateurCarte = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
insererCarte();
}
};
JPanel panInfo = new JPanel();
JButton insertion = new JButton("Insérez votre carte");
JTextArea info = new JTextArea();
insertion.addMouseListener(adaptateurCarte);
panInfo.setLayout(new BorderLayout());
panInfo.add(insertion, BorderLayout.NORTH);
panInfo.add(info, BorderLayout.SOUTH);
info.setBackground(Color.CYAN);
this.add(panInfo, BorderLayout.NORTH);
panForm.setLayout(new BorderLayout());
panForm.add(pan1, BorderLayout.NORTH);
panForm.add(pan2, BorderLayout.SOUTH);
this.add(panForm, BorderLayout.CENTER);
//Ajout de l'adaptateur au bouton :
MouseAdapter adaptateur1 = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
click();
}
};
bouton = new JButton("Rechargement");
bouton.addMouseListener(adaptateur1);
this.add(bouton, BorderLayout.SOUTH);
}
public void insererCarte() {
String message = "Bonjour " + carte25.getPrenom() + " " + carte25.getNom() + "\n";
message += "Votre solde est de " + carte25.getSoldeForfait() + " en charge rapide, soit " + carte25.getPrixParMinDeCharge() + " par minutes de charge";
message += "\nSuivez les instructions à l'écran pour recharger votre véhicule :";
info.setText(message);
}
public void click() {
}
} |
Partager