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
|
package test;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class IHM extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public IHM(){
// nos panels
JPanel pan1 = new JPanel();
JPanel pan2 = new JPanel();
JPanel pan4 = new JPanel();
// on les formes
pan1.setLayout(new BoxLayout(pan1, BoxLayout.LINE_AXIS));
pan2.setLayout(new BoxLayout(pan2, BoxLayout.LINE_AXIS));
pan4.setLayout(new BoxLayout(pan4, BoxLayout.LINE_AXIS));
// le Label
JLabel pres = new JLabel("Bienvenue sur Fast Food and Fat");
pres.setFont(new Font("Tahoma", Font.BOLD, 30));
pres.setForeground(Color.ORANGE);
pan1.add(pres);
// le Panneau Commande
JCheckBox check1 = new JCheckBox("Frite");
JCheckBox check2 = new JCheckBox("Coca");
JCheckBox check3 = new JCheckBox("Glace");
JCheckBox check4 = new JCheckBox("Big Mac");
JCheckBox check5 = new JCheckBox("Cheese Burger");
JCheckBox check6 = new JCheckBox("Potatoes");
JCheckBox check7 = new JCheckBox("Salade poulet");
JCheckBox check8 = new JCheckBox("Eau");
JCheckBox check9 = new JCheckBox("Ketchup");
JCheckBox check10 = new JCheckBox("Moutarde");
pan2.setLayout(new GridLayout(3,4));
pan2.add(check1);
pan2.add(check2);
pan2.add(check3);
pan2.add(check4);
pan2.add(check5);
pan2.add(check6);
pan2.add(check7);
pan2.add(check8);
pan2.add(check9);
pan2.add(check10);
// le Choix des boutons
JButton commander = new JButton("Commander et payer");
JButton reinit = new JButton("Réinitialiser la commande");
pan4.add(commander);
pan4.add(reinit);
// on ajout dans le JPanel
add(pan1);
add(pan2);
add(pan4);
}
public void paintComponent(Graphics g){
try {
Image img = ImageIO.read(new File("fastfood.jpg") );
g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
}
catch (IOException e){
e.printStackTrace();
}
}
} |
Partager