Bonjour à tous

Mon programme de fast food étant terminé, je m'attaque à l'IHM (ma première ) via Swing. Cependant, mon programme comporte 3 "secteurs": la gestion du stock, la cuisine et la commande et je ne sais pas comment gérer cela. Je m'explique: soit j'affiche 3 fenêtre au lancement (une pour chaque partie) soit j'affiche une première qui, via une ComboBox et un JButton me permet de choisir parmi 3 choix et suivant ce choix, le JPanel a affiché ne sera pas le même.

Qu'est ce qui vous semble le mieux? (ou tout du moins le plus simple?)

Autre question: Comment générer des JCheckBox pour chaque élément présent dans une liste (je pensais à une boucle for...)

Je vous poste le début de mon IHM:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
import java.awt.Color;
import java.awt.Font;
 
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 JFrame {
 
	public IHM(){
		this.setTitle("Fast food");
		this.setSize(600, 600);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
 
		// On instancie tous nos composants:
 
		Panfond principal = new Panfond();
		JPanel pan1 = new JPanel();
		JPanel pan2 = new JPanel();
		JPanel pan3 = new JPanel();
		JPanel pan4 = new JPanel();
		JPanel pan5 = new JPanel();
		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");
		JButton commander = new JButton("Commander et payer");
		JButton reinit = new JButton("Réinitialiser la commande");
		JLabel pres = new JLabel("Bienvenue sur Fast Food and Fat");
		Font ecriture = new Font("Tahoma", Font.BOLD, 30);
 
 
		this.setContentPane(principal);
 
		pres.setFont(ecriture);
		pres.setForeground(Color.ORANGE);
		pan1.setLayout(new BoxLayout(pan1, BoxLayout.LINE_AXIS));
		pan2.setLayout(new BoxLayout(pan2, BoxLayout.LINE_AXIS));
		pan3.setLayout(new BoxLayout(pan3, BoxLayout.LINE_AXIS));
		pan4.setLayout(new BoxLayout(pan4, BoxLayout.LINE_AXIS));
		pan5.setLayout(new BoxLayout(pan5, BoxLayout.PAGE_AXIS));
 
 
 
		pan1.add(pres);
 
 
 
 
		pan2.add(check1);
		pan2.add(check2);
		pan2.add(check3);
		pan2.add(check4);
		pan2.add(check5);
 
		pan3.add(check6);
		pan3.add(check7);
		pan3.add(check8);
		pan3.add(check9);
		pan3.add(check10);
 
		pan4.add(commander);
		pan4.add(reinit);
 
 
		pan5.add(pan1);		
		pan5.add(pan2);
		pan5.add(pan3);
		pan5.add(pan4);
 
 
 
 
 
		this.getContentPane().add(pan5);
		this.setVisible(true);
	}
 
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
 
 
 
 
public class Panfond extends JPanel {
	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();
		}
	}
}
Voilà, tous vos conseils sont les bienvenus!