IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Java Discussion :

Comment penser mon IHM?


Sujet :

Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Ingénieur de recherche
    Inscrit en
    Décembre 2011
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur de recherche
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 52
    Par défaut Comment penser mon IHM?
    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!

  2. #2
    Modérateur
    Avatar de XxArchangexX
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2012
    Messages
    1 159
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Par défaut
    Tout d'abord si tu souhaites avoir les Choix dans la même fenêtre tu peux faire des onglets c'est sympathique.
    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
     
     
    public class Fenêtre{
     
    public Fenêtre(){
    private JTabbedPane _onglets = new JTabbedPane();
     
    // les onglets sont des JPanel qui sont les vues de chacun de tes choix
    OngletGestionClient _ongGestionClient = new OngletGestionClient();
    OngletGestionProduit _ongGestionProduit = new OngletGestionProduit();
     
    _onglets.addTab("", new ImageIcon("./imagesdecors/accueil.jpg"), _ongGestionClient , "Bienvenue");
     
    _onglets.addTab("Gestion Client", new ImageIcon("./imagesdecors/ajout.jpg"), _OngletGestionProduit , "ajouter un Livre");
     
    mainFrame.add(_onglets);
    }
    }
    Pour ta première conception avec un JComboBox tu peux lui associer un listener,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    ControleurListeProduit controle = new ControleurListeProduit(this);
    produit = new JComboBox(ListeCours);
    produit.addItemListener(controle);
     
    // pour l'entête de la classe ControleurListeProduit 
    public class ControleurListeProduit implements ItemListener {}
    et quand l'item de la comboBox change tu effectues le switch de la fenêtre
    L'Etat est bien administré quand l'escalier de l'école est usé et que l'herbe croît sur celui du tribunal.

    Modérateur BI

  3. #3
    Modérateur
    Avatar de XxArchangexX
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2012
    Messages
    1 159
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Par défaut
    Si tu veux test sans te prendre la tête .

    Une classe Fenêtre principale
    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
     
    package test;
     
    import javax.swing.JFrame;
    import javax.swing.JTabbedPane;
     
    public class FenetrePrincipale extends JFrame{
     
    	public FenetrePrincipale(){
     
    		JTabbedPane _onglets = new JTabbedPane();
     
    		// les onglets sont des JPanel qui sont les vues de chacun de tes choix
    		IHM _ongCommande = new IHM();
    		Ong_Cuisine _ongCuisine= new Ong_Cuisine();
    		Ong_Stock _ongsotck = new Ong_Stock();
    		//OngletGestionProduit _ongGestionProduit = new OngletGestionProduit();
     
    		_onglets.addTab("Commande",null, _ongCommande , "Bienvenue");
     
    		_onglets.addTab("Cuisine",null, _ongCuisine , "gerer la cuisine");
    		_onglets.addTab("Gestion des stocks",null, _ongsotck , "gestion du stock");
     
    		add(_onglets);
     
    		this.setTitle("Fast food");
    		this.setSize(600, 600);
    		this.setLocationRelativeTo(null);
    		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		this.setVisible(true);
     
    	}
     
    }
    Une class IHM (onglet commande)
    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
    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();
    		}
    	}
     
    }
    Une classe onglet cuisine
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
    package test;
     
    import javax.swing.JPanel;
     
    public class Ong_Cuisine extends JPanel{
     
    	public Ong_Cuisine(){
     
    	}
     
    }
    Une classe onglet stock
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    package test;
     
    import javax.swing.JPanel;
     
    public class Ong_Stock extends JPanel{
     
    }
    Une classe Main de l'application
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    package test;
     
    public class main {
     
    	/**
             * @param args
             */
    	public static void main(String[] args) {
    		FenetrePrincipale IHM = new FenetrePrincipale();
     
    	}
     
    }
    L'Etat est bien administré quand l'escalier de l'école est usé et que l'herbe croît sur celui du tribunal.

    Modérateur BI

Discussions similaires

  1. comment changé mon ip sous dos
    Par maichants20 dans le forum Windows 2000/Me/98/95
    Réponses: 2
    Dernier message: 14/07/2005, 13h25
  2. Réponses: 1
    Dernier message: 24/01/2005, 06h55
  3. [Servlet] Comment référencer mon fichier CSS
    Par fytheone dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 07/01/2005, 09h58
  4. Comment faire mon choix
    Par SoubeigAbraham dans le forum Débuter
    Réponses: 1
    Dernier message: 07/10/2004, 14h29
  5. Réponses: 7
    Dernier message: 04/06/2004, 15h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo