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

AWT/Swing Java Discussion :

impossible de faire fonctionner le gridlayout


Sujet :

AWT/Swing Java

  1. #1
    Membre confirmé Avatar de oceane751
    Profil pro
    Intégrateur Web
    Inscrit en
    Novembre 2004
    Messages
    1 280
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Intégrateur Web

    Informations forums :
    Inscription : Novembre 2004
    Messages : 1 280
    Points : 575
    Points
    575
    Par défaut impossible de faire fonctionner le gridlayout
    bonjour à tous!
    j'aimerais bien placer certain element de ma fenetre.
    j'aimerais beaucoup mettre "entree" (sous forme de titre) puis les entrées en dessous
    les crepes salées (sous forme de titre) puis les crepes salées en dessous
    idem pour les crepes sucrées et les boissons.

    voici le code :
    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
    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
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
     
    package com.carte_crepee.test;
     
    import java.awt.Button;
    import java.awt.Checkbox;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.Label;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.math.BigDecimal;
    import java.math.BigInteger;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import javax.swing.JOptionPane;
    import javax.swing.*;
    import java.awt.Choice;
    import java.util.Properties;
    import java.io.*;
    import java.awt.*;
    import com.carte_crepee.outil.Produit;
     
    public class carte extends Frame implements ActionListener
    {
        private Properties props = new Properties();
        private Hashtable associationProduitsPrix= new Hashtable();
     
        private GridLayout grid;
             private TextField text;
             private TextField serveur;
                private Label entree;
                 private Label crepesalee;
                 private Label crepesucree;
                 private Label boisson;
                private Checkbox salade;
     
                private Label lab;
                private Label lab2;
                private Label lab3;
     
                private Choice maCombo;
                private Checkbox melon;
                private Label cs;
            private Checkbox jf;
          private Button bouton;
        private Button quitter;
     
        class WindowEventHandler extends WindowAdapter
        {
            public void windowClosing(WindowEvent we)
            {
                dispose(); // quitte l'objet
            }
        }
     
        public carte()
        {
            super("creperie");
            addWindowListener(new WindowEventHandler());
            // Lit les données du fichier de propriétés
            //Properties props = new Properties();
            try
            {
                props.load(new FileInputStream("carte.txt"));
            }
            catch (FileNotFoundException e)
            {
                System.err.println("Fichier carte.txt non trouvé");
            }
            catch (IOException e)
            {
                System.err.println("Impossible de lire le fichier carte.txt");
            }
            // Création des champs
            //nombre d'article = au nombre de clé dans le fichier properties
            //puisque chaque article forme un couple de clés libellé/prix
            entree = new Label ("entree");
                add(entree);
                crepesalee = new Label("crepe salée");
                add(crepesalee);
                crepesucree = new Label("crepe sucree");
                add(crepesucree);
                boisson = new Label("boisson");
                add(boisson);
     
                Panel panel = new Panel();
                  GridLayout jo = new GridLayout(3, 2, 5, 5);
                     panel.setLayout(jo);
                     panel.applyComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT);
     
     
     
            int length=props.size()/2;
            for (int i=0;i<length;i++)
            {
     
                String valeur = props.getProperty("libelle_"+i);
                //String crepe = props.getProperty("libelle_crepe_"+i);
                if (valeur!=null)
                {
     
                    Choice combo = new Choice();
                    combo.add("1");
                    combo.add("2");
                   add(combo);
     
     
                    Checkbox checkbox = new Checkbox(valeur);
                    add(checkbox);
     
                    String prix = props.getProperty("prix_"+i);
                    Label label = new Label(prix);
                    add(label);
                    Produit produit = new Produit();
                    produit.setComboQuantite(combo);
                    produit.setPrix(new BigDecimal(prix));
     
                    // ajout dans la table de hash pour le calcul du prix
                    // la clé étant l'objet chechbox correspondant à l'article
                    associationProduitsPrix.put(checkbox, produit);
     
     
                }
            }
            // on met les boutons
             text = new TextField ("numero de table");
             add(text);
             serveur = new TextField ("nom du serveur");
             add(serveur);
            bouton = new Button("ticket");
            add(bouton);
            quitter = new Button("quitter l'application");
            add(quitter);
            // on intialise les évènements sur les boutons
            initBoutonsListeners();
            // Initialise la fenêtre
            setLayout(new FlowLayout()); //sinon n'affiche qu'un seul element ds la fenetre
            setBackground(Color.white);
            setForeground(Color.black);
     
     
     
     
     
            quitter.addActionListener(this);
        }
     
        // Initialise les évènements des boutons
        private void initBoutonsListeners()
        {
            bouton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    BigDecimal total = new BigDecimal("0.00"); //initialise à 0
                    Enumeration enu = associationProduitsPrix.keys();
                    while (enu.hasMoreElements())
                    {
                        Checkbox check = (Checkbox)enu.nextElement();
                        if (check.getState()) // si un check a été coché
                        {
                            Produit produit = (Produit)associationProduitsPrix.get(check);
                            BigDecimal prix = produit.getPrix();
                            BigDecimal quantite = new BigDecimal (new BigInteger(produit.getComboQuantite().getSelectedItem()));
                            total = total.add(prix.multiply(quantite));
     
                        }
                    }
                    JOptionPane.showMessageDialog(null,"A la bonne crêpe" + "\n" + "67 rue de vaugirard" + "\n" + "75006 paris" + "\n" + " Tel : 01.45.44.38.46" + "\n" + "serveur : " + serveur.getText() + "\n" +   "Total : " + total+ "\n" +   "Numero de table : "+text.getText()+ "\n" );
                }
            });
        }
        public void actionPerformed(ActionEvent event)
        {
            if (event.getSource() == quitter)
            {
                dispose();
                System.exit(0);
            }
        }
     
     
        public static void main(String[] args)
        {
            Frame f = new carte();
     
     
               // f.setContentPane(panel);
                     f.setTitle("Ticket client");
                   f.setBounds(100,100,300,200);
     
            f.pack();
            f.setSize(500,500);
            f.show();
        }
    }
    j'ai un peu de mal alors si quelqu'un pourrait m'aider ce serait vraiment tres sympas.. je patoge completement

  2. #2
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    je redi ce que je disait hier
    utilise un GridBagLayout.

    essaye de faire un petit dessin avec ce que tu veux et je t'explique comment utiliser GridBagLayout?

  3. #3
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    si je peut me permettre aussi mais je te critique pas:

    - mieu vaux faire commencer les classes par des majuscule.
    - tu utilise AWT et Swing (JOptionPane) pourquoi ne pas tout faire en Swing?
    - essaye d'indenter ton code correctement.

  4. #4
    Membre confirmé Avatar de oceane751
    Profil pro
    Intégrateur Web
    Inscrit en
    Novembre 2004
    Messages
    1 280
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Intégrateur Web

    Informations forums :
    Inscription : Novembre 2004
    Messages : 1 280
    Points : 575
    Points
    575
    Par défaut
    re
    j'ai fait un dessin pas top mais bon ça te donne une idée de ce que je veux.

    mais bon, j'ai un oral mardi et j'ai une chance (si on peut appelé ça de la chance) sur 5 de tomber sur ce projet. j'ai plus le temps de m'y remettre, il faut que je fasse les dossiers de tous mes projets.
    j'aimerais juste presenté une appli un peu potable..
    en plus j'ai pas fait l' UML, ché pa comment faire. enfin bref, je laisse les pieces jointes dans l'eventualité où quelqu'un pourrait juste me faire la mise en page (enfin si on peut appelé ça comme ça) . c'est pas dans mes habitudes de demander ça mais j'ai pas trop le choix.

    ce que j'aimerais comme "mise en page"
    Nom : DESSIN.JPG
Affichages : 82
Taille : 13,3 Ko

    voilà ce que j'ai
    Nom : creperie.jpg
Affichages : 69
Taille : 17,1 Ko

    désolée si ça enerve certaine personne.
    enfin si personne veut m'aider c'est pas grave.

    merci d'avance à celui ou ceux qui veulent m'aider.

  5. #5
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    bonjour

    t'utilise un FlowLayout. c'est pour ca que c'est comme ca.
    regarde j'ai vite fais un truc avec un GridBagLayout.

    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
    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
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
     
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
     
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JSeparator;
    import javax.swing.JTextField;
    import javax.swing.JPanel;
     
    /**
     * Created by IntelliJ IDEA.
     * User: bebe
     * Date: 12-Jun-2006
     * Time: 07:47:57
     * To change this template use File | Settings | File Templates.
     */
    public class Carte2 extends JPanel {
     
        private JLabel entreeLabelTitle = new JLabel();
        private JSeparator entreeSeparator = new JSeparator();
        private JLabel entree1Label = new JLabel();
        private JTextField entree1TextField = new JTextField();
        private JLabel entree2Label = new JLabel();
        private JLabel entreeSuiteLabel = new JLabel();
        private JLabel crepeSaleeLabelTitle = new JLabel();
        private JSeparator crepeSalerSeparator = new JSeparator();
        private JLabel crepeSaleeType1Label = new JLabel();
        private JTextField crepeSalerType1TextField = new JTextField();
        private JLabel suiteSaleesLabel = new JLabel();
        private JTextField suiteSalerTextField = new JTextField();
        private JLabel crepeSucreeLabelTitle = new JLabel();
        private JSeparator crepSucrerSeparator = new JSeparator();
        private JLabel crepeSucrerType1Label = new JLabel();
        private JLabel suiteSucrerLabel = new JLabel();
        private JTextField crepeSucrerType1TextField = new JTextField();
        private JTextField suiteSucrerTextField = new JTextField();
        private JLabel boissonLabelTitle = new JLabel();
        private JLabel numeroTableLabel = new JLabel();
        private JSeparator boissonSeparator = new JSeparator();
        private JLabel cocaLabel = new JLabel();
        private JTextField cocaTextField = new JTextField();
        private JLabel fantaLabel = new JLabel();
        private JTextField fantaTextField = new JTextField();
        private JButton ticketButton = new JButton();
        private JButton quitterButton = new JButton();
        private JComboBox numeroTableCombobox = new JComboBox();
        private JLabel nomServeurLabel = new JLabel();
        private JTextField nomServeurTextField = new JTextField();
        private JTextField totalTextField = new JTextField();
        private JSeparator totalSeparator = new JSeparator();
        private JLabel totalLabel = new JLabel();
     
        public Carte2() {
            initGui();
     
        }
     
        private void initGui(){
            setLayout(new GridBagLayout());
     
            entreeLabelTitle.setText("Entrees :");
            entreeLabelTitle.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 15));
            entreeLabelTitle.setForeground(new Color(115, 24, 0));
            entree1Label.setText("Une entree ");
            entree1TextField.setPreferredSize(new Dimension(85, 20));
            entree1TextField.setMinimumSize(new Dimension(85, 20));
            entree2Label.setText("Second entree ");
            entreeSuiteLabel.setText("suite...");
            crepeSaleeLabelTitle.setText("Crepes salees :");
            crepeSaleeLabelTitle.setFont(new Font("Verdana", 1, 15));
            crepeSaleeLabelTitle.setForeground(new Color(115, 24, 0));
            crepeSaleeType1Label.setText("Type de crepe salee");
            crepeSalerType1TextField.setPreferredSize(new Dimension(85, 20));
            crepeSalerType1TextField.setMinimumSize(new Dimension(85, 20));
            suiteSaleesLabel.setText("suite...");
            suiteSalerTextField.setMinimumSize(new Dimension(85, 20));
            suiteSalerTextField.setPreferredSize(new Dimension(85, 20));
            crepeSucreeLabelTitle.setText("Crepes sucres :");
            crepeSucreeLabelTitle.setFont(new Font("Verdana", 1, 15));
            crepeSucreeLabelTitle.setForeground(new Color(115, 24, 0));
            crepeSucrerType1Label.setText("Type de crepe sucrer");
            suiteSucrerLabel.setText("suite...");
            crepeSucrerType1TextField.setPreferredSize(new Dimension(85, 20));
            crepeSucrerType1TextField.setMinimumSize(new Dimension(85, 20));
            suiteSucrerTextField.setMinimumSize(new Dimension(85, 20));
            suiteSucrerTextField.setPreferredSize(new Dimension(85, 20));
            boissonLabelTitle.setText("Boissons :");
            boissonLabelTitle.setFont(new Font("Verdana", 1, 15));
            boissonLabelTitle.setForeground(new Color(115, 24, 0));
            numeroTableLabel.setText("Numero de table :");
            cocaLabel.setText("Coca");
            cocaTextField.setPreferredSize(new Dimension(85, 20));
            cocaTextField.setMinimumSize(new Dimension(85, 20));
            fantaLabel.setText("Fanta");
            fantaTextField.setMinimumSize(new Dimension(85, 20));
            fantaTextField.setPreferredSize(new Dimension(85, 20));
            ticketButton.setText("Ticket");
            quitterButton.setText("Quitter");
            numeroTableCombobox.setPreferredSize(new Dimension(75, 20));
            numeroTableCombobox.setMinimumSize(new Dimension(75, 20));
            nomServeurLabel.setText("Nom du serveur :");
            totalTextField.setMinimumSize(new Dimension(85, 20));
            totalTextField.setPreferredSize(new Dimension(85, 20));
            totalTextField.setEditable(false);
            totalLabel.setText("Total");
            this.add(entreeLabelTitle,
                     new GridBagConstraints(0, 2, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(10, 5, 0, 0), 0, 0));
            this.add(entreeSeparator,
                     new GridBagConstraints(1, 3, GridBagConstraints.REMAINDER,
                                            1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
                                            new Insets(0, 25, 0, 5), 0, 0));
            this.add(entree1Label,
                     new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(15, 25, 0, 0), 0, 0));
            this.add(entree1TextField,
                     new GridBagConstraints(1, 4, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(12, 0, 0, 5), 0, 0));
            this.add(entree2Label,
                     new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 25, 0, 0), 0, 0));
            this.add(entreeSuiteLabel,
                     new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 25, 0, 0), 0, 0));
            this.add(crepeSaleeLabelTitle,
                     new GridBagConstraints(0, 7, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(25, 5, 0, 0), 0, 0));
            this.add(crepeSalerSeparator,
                     new GridBagConstraints(1, 8, GridBagConstraints.REMAINDER,
                                            1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
                                            new Insets(0, 25, 0, 5), 0, 0));
            this.add(crepeSaleeType1Label,
                     new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(15, 25, 0, 0), 0, 0));
            this.add(crepeSalerType1TextField,
                     new GridBagConstraints(1, 9, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(12, 0, 0, 5), 0, 0));
            this.add(suiteSaleesLabel,
                     new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 25, 0, 0), 0, 0));
            this.add(suiteSalerTextField,
                     new GridBagConstraints(1, 10, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(3, 0, 0, 5), 0, 0));
            this.add(crepeSucreeLabelTitle,
                     new GridBagConstraints(0, 11, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(25, 5, 0, 0), 0, 0));
            this.add(crepSucrerSeparator,
                     new GridBagConstraints(1, 12, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
                                            new Insets(0, 25, 0, 5), 0, 0));
            this.add(crepeSucrerType1Label,
                     new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(15, 25, 0, 0), 0, 0));
            this.add(suiteSucrerLabel,
                     new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 25, 0, 0), 0, 0));
            this.add(crepeSucrerType1TextField,
                     new GridBagConstraints(1, 13, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(12, 0, 0, 5), 0, 0));
            this.add(suiteSucrerTextField,
                     new GridBagConstraints(1, 14, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(3, 0, 0, 5), 0, 0));
            this.add(boissonLabelTitle,
                     new GridBagConstraints(0, 15, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(25, 5, 0, 0), 0, 0));
            this.add(numeroTableLabel,
                     new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(8, 0, 0, 0), 0, 0));
            this.add(boissonSeparator,
                     new GridBagConstraints(1, 16, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
                                            new Insets(0, 25, 0, 5), 0, 0));
            this.add(cocaLabel,
                     new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(15, 25, 0, 0), 0, 0));
            this.add(cocaTextField,
                     new GridBagConstraints(1, 17, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(12, 0, 0, 5), 0, 0));
            this.add(fantaLabel,
                     new GridBagConstraints(0, 18, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 25, 0, 0), 0, 0));
            this.add(fantaTextField,
                     new GridBagConstraints(1, 18, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(3, 0, 0, 5), 0, 0));
            this.add(ticketButton,
                     new GridBagConstraints(2, 21, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE,
                                            new Insets(10, 0, 5, 5), 0, 0));
            this.add(quitterButton,
                     new GridBagConstraints(3, 21, 1, 1, 0.0, 1.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE,
                                            new Insets(10, 0, 5, 5), 0, 0));
            this.add(numeroTableCombobox,
                     new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(5, 5, 10, 5), 0, 0));
            this.add(nomServeurLabel,
                     new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(8, 0, 0, 0), 0, 0));
            this.add(nomServeurTextField,
                     new GridBagConstraints(2, 0, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
                                            new Insets(5, 5, 0, 5), 0, 0));
            this.add(totalTextField,
                     new GridBagConstraints(1, 20, GridBagConstraints.REMAINDER,
                                            1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
                                            new Insets(7, 0, 0, 5), 0, 0));
            this.add(totalSeparator,
                     new GridBagConstraints(0, 19, GridBagConstraints.REMAINDER,
                                            1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                                            new Insets(15, 25, 0, 5), 0, 0));
            this.add(totalLabel,
                     new GridBagConstraints(0, 20, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                                            new Insets(10, 25, 0, 0), 0, 0));
        }
     
     
     
        public static void main(String[] args) {
            JFrame myFrame = new JFrame("Carte");
            myFrame.add(new Carte2());
            myFrame.pack();
            myFrame.setLocationRelativeTo(null);
            myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myFrame.setVisible(true);
        }
     
    }
    ca donne ca:

    http://www.developpez.net/forums/att...1&d=1150091461


    mais ton dessin est mal fais pour voir exactement qu'est ce que tu veut.
    et ton code il manque une classe Produit.

    ca derange pas de te le faire.
    je revise mon cour de Java ici moi j'ai examen cet aprem
    Images attachées Images attachées  

  6. #6
    Membre confirmé Avatar de oceane751
    Profil pro
    Intégrateur Web
    Inscrit en
    Novembre 2004
    Messages
    1 280
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Intégrateur Web

    Informations forums :
    Inscription : Novembre 2004
    Messages : 1 280
    Points : 575
    Points
    575
    Par défaut
    ba di dc c'est bien fait
    c'est un peu ce que je veux
    en faite tout est stocker dans un fichier texte du style :
    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
     
    libelle_0 = salade composée
    prix_0 = 5.00
    libelle_1 = melon
    prix_1 = 3.00
    libelle_2 = jambon fromage
    prix_2 = 7.00
    libelle_3 = complete
    prix_3 = 10.00
    libelle_4 = crepe au sucre
    prix_4 = 7.00
    libelle_5 = crepe au chocolat
    prix_5 = 8.00
    libelle_6 = bollée de cidre
    prix_6 = 4.00
    libelle_7 = bouteille de cidre
    prix_7 = 7.50
    mais c'est vrai que j'aimerais bien garder mon code de base avec les checkbox ect
    et avoir comme tu as fait des "rubrique " : entree, crepe salée ...

    et sinon (j'allais oublié) ma classe produit :
    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
     
    package com.carte_crepee.outil;
     
     
    import java.awt.Choice;
    import java.math.BigDecimal;
     
    public class Produit
    {
        private BigDecimal prix;
        private Choice comboQuantite;
     
        /**
         * @return
         */
        public Choice getComboQuantite()
        {
            return comboQuantite;
        }
     
        /**
         * @return
         */
        public BigDecimal getPrix()
        {
            return prix;
        }
     
        /**
         * @param choice
         */
        public void setComboQuantite(Choice choice)
        {
            comboQuantite = choice;
        }
     
        /**
         * @param decimal
         */
        public void setPrix(BigDecimal decimal)
        {
            prix = decimal;
        }
     
    }
    ça me fais ch** de devoir faire obligatoirement une PTI en objet.. enfin que se soit obligatoire pour avoir toutes les compétences pour le diplome..

    bon courage pour ton oral cet aprem

  7. #7
    Membre éclairé
    Avatar de bbclone
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    537
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 537
    Points : 704
    Points
    704
    Par défaut
    ok
    ben c'est pas compliquer ton truc:

    mais avant que je t'exlplique comment tu doit faire

    je revient sur des petit points:
    ton fichier est comme ca:
    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
     
    libelle_0 = salade composée
    prix_0 = 5.00
    libelle_1 = melon
    prix_1 = 3.00
    libelle_2 = jambon fromage
    prix_2 = 7.00
    libelle_3 = complete
    prix_3 = 10.00
    libelle_4 = crepe au sucre
    prix_4 = 7.00
    libelle_5 = crepe au chocolat
    prix_5 = 8.00
    libelle_6 = bollée de cidre
    prix_6 = 4.00
    libelle_7 = bouteille de cidre
    prix_7 = 7.50
    c'est pas plus facile pour toi si tu met tout dans une seule ligne?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    salade composée	5.00
    melon			3.00
    jambon fromage		7.00
    complete		10.00
    crepe au sucre		7.00
    crepe au chocolat 	8.00
    bollée de cidre		4.00
    bouteille de cidre	7.50
    ?
    a quoi sert libelle_* et prix_*?


    apres y'a un autre truc.
    tu veut des titre par categorie mais comment je sais quel produit est de quel categorie? je croi qui manque quelque chose :-S (et c'est pas mieu de l'xml? )

    tu veut des CheckBox pas de probleme. tu veut sur chaque produit dans le fichier? :-)

    et y'a toujour une question t'a pas repondu.
    pourquoi tu melange swing et awt?

    bon je risque plus de repondre aujourd'hui.
    je fais ton truc demain si c'est bien clair :-)

    a demain

    merci du soutien :-)

Discussions similaires

  1. impossible de faire fonctionner DisplayTag
    Par zanzan212 dans le forum Struts 1
    Réponses: 4
    Dernier message: 02/07/2007, 08h45
  2. [Requête] Impossible de faire fonctionner !
    Par Nesta92 dans le forum Requêtes et SQL.
    Réponses: 3
    Dernier message: 17/04/2007, 09h38
  3. Réponses: 5
    Dernier message: 05/12/2006, 23h57
  4. Réponses: 5
    Dernier message: 22/03/2006, 10h39
  5. impossible de faire fonctionner phppgadmin et pgdmin3
    Par le_ben dans le forum PostgreSQL
    Réponses: 6
    Dernier message: 09/12/2004, 14h27

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