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 :

JtabbedPane et Jpanel


Sujet :

AWT/Swing Java

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut JtabbedPane et Jpanel
    slt !!!!!

    j'ai un petit soucis depuis 1 semaine je n'arrive pas a ecrire dans des labels donc je m'explique ........

    mon programme à des onglets et chaque onglets hérite d'une classe qui est en extends JPanel donc 2 onglets et 2 classes ......... dans le premier onglet lorsque je clique sur un JRadioButton je récupére un String qui est automatiquement attribuer a mes fonctions qui eux ce trouve dans le deuxiéme onglet ...... mais lorsque je clique sur le deuxiéme onglet je n'ai rien d'afficher dans mes labels par contre pour vérifier que mon programme marche bien j'ai attribué à chaque labels un System.out.print(); et tous marche a merveille sauf l'affiche qui est vide ..... pourquoi l'affichage ne marche pas ??? .......

    petit bout de code de ma Classe informations c'est mon JRadioButton ....
    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
    private void getJrB(String[] t,String[] w) {
             a = 16;
            ButtonGroup group = new ButtonGroup();
            for (int i = 0;i < t.length && i<w.length;i++) {
                Pers1 += 1;
                 a += 22;
            final JRadioButton rb = new JRadioButton(t[i]);
            rb.setBounds(new Rectangle(5, a, 20, 23));
            rb.setName("Pers1_"+Pers1);
            rb.setText(w[i]);
            jPanel.add(rb);
            group.add(rb);
            jPanel.repaint();
            rb.addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                   if (e.getStateChange() == ItemEvent.SELECTED) {
                    JRadioButton obj = (JRadioButton)e.getItem();
                    //JOptionPane.showMessageDialog(null,"type :"+obj.getText());
                    //ID = obj.getText();
                    Structure_P1 wb = new Structure_P1();
                    wb.BootFonct(obj.getText());
                    //tg.setText(obj.getText());
                    } 
     
                }
            }
            );
     
            }
            a = 0;
        }
    ma classe Structure-P1 qui elle dois affiché tous mes résultat ........
    je n'ai laissé que 2 system.out.print(); dans le code car trop de caractére ....
    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
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
     
    public class Structure_P1 extends JPanel{
     
        private static final long serialVersionUID = 1L;
     
        private JPanel jPanel = null;
        private JButton jb = null;
     
        private JLabel LCV = getL(600, 100, 92, 40,"CV"); //tous les label sont créer de la même façons
        public JLabel azer = null;
        private JScrollPane js = null;
        private org.jdom.Document document;
        private Element racine;
        private String Double,pre,ReducCons1,ReducVoy1;
        private String ReducCons2,ReducCons3,ReducVoy2,ReducVoy3;
        private String a,stockvoy,stockcons;
        String[] strDate = new String[2];
        //String ID = "76";
        private int ConvertIntES,ConvertIntCV,stress,stress2,stress3,reduc2,reduc,dizaine,
                unite,compt,compt2,maxcompt=0,maxcompt2=0,AddCons=0,AddVoy=0,AddVoy1=0,AddCons1=0,
                AddVoy2=0,AddCons2=0,AddVoy3=0,AddCons3=0,AddVoy4=0,AddCons4=0,NomVoy=0,NomCons=0,Prenom1Voy=0,Prenom1Cons=0,
                Tab = 0,Tab1 = 0,Tab2 = 0,Tab3 = 0,Tab4 = 0,Tab5 = 0,Tab6 = 0,Tab7 = 0,Tab8 = 0;
        //informations id = new informations();
     
        private JLabel getL(int x, int y, int l,int h, String T) {
            JLabel L = null;
            if(L==null) {
                L = new JLabel();
                L.setBounds(new Rectangle(x, y, l, h));
                //L.setText(T);
                L.setAutoscrolls(true);
                L.setForeground(Color.blue);
                L.setBorder(javax.swing.BorderFactory.createTitledBorder(T));
            }
            return L;
        }
     
        public void BootFonct(String po)
        {
                        AfficheStructure(po);
        }
     
        public JScrollPane JS() {
            if (js == null) {
                js = new JScrollPane();
                js.setViewportView(getJPanel());
            }
            return js;
        }
     
        public JPanel getJPanel() {
            informations qs = new informations();
            if (jPanel == null) {
                azer = new JLabel();
                azer.setBounds(new Rectangle(500, 500, 100, 30));
                azer.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
                jPanel = new JPanel();
                jPanel.setLayout(null);
                jPanel.add(getJButton1());
                jPanel.add(LnomR7);
                jPanel.add(Lprenom1R7);
                jPanel.add(Lprenom2R7);
                jPanel.add(Lprenom3R7);
                jPanel.add(Lprenom4R7);
                jPanel.add(LnomR5);
                jPanel.add(Lprenom1R5);
                jPanel.add(Lprenom2R5);
                jPanel.add(Lprenom3R5);
                jPanel.add(Lprenom4R5);
                jPanel.add(LnomR3);
                jPanel.add(Lprenom1R3);
                jPanel.add(Lprenom2R3);
                jPanel.add(Lprenom3R3);
                jPanel.add(Lprenom4R3);
                jPanel.add(LnomR1);
                jPanel.add(Lprenom1R1);
                jPanel.add(Lprenom2R1);
                jPanel.add(Lprenom3R1);
                jPanel.add(Lprenom4R1);
                jPanel.add(Lnom);
                jPanel.add(Lprenom1);
                jPanel.add(Lprenom2);
                jPanel.add(Lprenom3);
                jPanel.add(Lprenom4);
                jPanel.add(LnomR2);
                jPanel.add(Lprenom1R2);
                jPanel.add(Lprenom2R2);
                jPanel.add(Lprenom3R2);
                jPanel.add(Lprenom4R2);
                jPanel.add(LnomR4);
                jPanel.add(Lprenom1R4);
                jPanel.add(Lprenom2R4);
                jPanel.add(Lprenom3R4);
                jPanel.add(Lprenom4R4);
                jPanel.add(LnomR6);
                jPanel.add(Lprenom1R6);
                jPanel.add(Lprenom2R6);
                jPanel.add(Lprenom3R6);
                jPanel.add(Lprenom4R6);
                jPanel.add(LnomR8);
                jPanel.add(Lprenom1R8);
                jPanel.add(Lprenom2R8);
                jPanel.add(Lprenom3R8);
                jPanel.add(Lprenom4R8);
                jPanel.add(Ladd7);
                jPanel.add(Ladd5);
                jPanel.add(Ladd3);
                jPanel.add(Ladd1);
                jPanel.add(Ladd);
                jPanel.add(Ladd2);
                jPanel.add(Ladd4);
                jPanel.add(Ladd6);
                jPanel.add(Ladd8);
                jPanel.add(LEXP);
                jPanel.add(LEXP2);
                jPanel.add(LNA);
                jPanel.add(LAD);
                jPanel.add(LES);
                jPanel.add(LIS);
                jPanel.add(LMI);
                jPanel.add(LNF);
                jPanel.add(LCV);
                jPanel.add(azer);
                jPanel.add(getJT("azer"));
                jPanel.setPreferredSize(new Dimension (980,500));
            }
            return jPanel;
        }
     
        private void getxml() {
            //L'on crée un instance du parseur SAXBuilder
            SAXBuilder xml = new SAXBuilder();
            try {
                //L'on crée un nouveau document JDOM avec en argumant le fichier XML
                //Le parsing est terminé ;)
                document = xml.build(new File("xml/therapeute.xml"));
     
     
            } catch(Exception e){
                JOptionPane.showMessageDialog(null, "Le fichier XML n'a pas etais trouvé l'application va s'arréter et aller verifier si votre xml existe @++ ... lol ... ");
                System.exit(0);
            }
     
            //L'on initialise un nouvel element racine avec l'element racine du document.
            racine = document.getRootElement();
        }
     
        private void AfficheStructure(String ID) {
            getxml();
            AddVoy3 = 0;
            AddVoy2 = 0;
            AddCons2 = 0;
            AddCons3 = 0;
            AddVoy1 = 0;
            AddCons1 = 0;
     
            List listEtudiants = racine.getChildren("therapeute");
            Iterator x = listEtudiants.iterator();
            while(x.hasNext()) {
                Element courant = (Element)x.next();
                Iterator x2 = courant.getChildren("patients").iterator();
                while(x2.hasNext()) {
                    Element courant2 = (Element)x2.next();
                    Iterator x3 = courant2.getChildren("patient").iterator();
                    while(x3.hasNext()) {
                        String[] strPrenom = new String[4];
                        int i=0;
                        Element courant3 = (Element)x3.next();
                        if (courant3.getAttributeValue("id").equals(ID)) {
                            strDate = courant3.getChild("date_naissance").getText().split("-");
                            if (courant3.getChild("nomjf").getText() != "") {
                                Lnom.setText(courant3.getChild("nomjf").getText());
                                System.out.print(courant3.getChild("nomjf").getText());
                                reduction(courant3.getChild("nomjf").getText());
                                LnomR7.setText(ReducVoy3);
                                LnomR5.setText(ReducVoy2);
                                LnomR3.setText(ReducVoy1);
                                LnomR1.setText(stockvoy);
                                //Lnom.setText(pre);
                                LnomR2.setText(stockcons);
                                LnomR4.setText(ReducCons1);
                                LnomR6.setText(ReducCons2);
                                LnomR8.setText(ReducCons3);
                            } else {
                                Lnom.setText(courant3.getChild("nom").getText());
                                System.out.print(courant3.getChild("nom").getText());
                                reduction(courant3.getChild("nom").getText());
                                LnomR7.setText(ReducVoy3);
                                LnomR5.setText(ReducVoy2);
                                LnomR3.setText(ReducVoy1);
                                LnomR1.setText(stockvoy);
                                //Lnom.setText(pre);
                                LnomR2.setText(stockcons);
                                LnomR4.setText(ReducCons1);
                                LnomR6.setText(ReducCons2);
                                LnomR8.setText(ReducCons3);
                            }
     
                            NomVoy = StringToInt(ReducVoy1);
                            NomCons = StringToInt(ReducCons1);
     
                            Iterator x4 = courant3.getChildren("prenoms").iterator();
                            while(x4.hasNext()) {
                                Element courant4 = (Element)x4.next();
                                Iterator x5 = courant4.getChildren("prenom").iterator();
                                while(x5.hasNext()) {
                                    Element courant5 = (Element)x5.next();
                                    strPrenom[i] = courant5.getText();
                                    i++;
                                }
                                Lprenom1.setText(strPrenom[0]);
                                reduction(strPrenom[0]);
                                Lprenom1R7.setText(ReducVoy3);
                                Lprenom1R5.setText(ReducVoy2);
                                Lprenom1R3.setText(ReducVoy1);
                                Lprenom1R1.setText(stockvoy);
                                //Lprenom1.setText(pre);
                                Lprenom1R2.setText(stockcons);
                                Lprenom1R4.setText(ReducCons1);
                                Lprenom1R6.setText(ReducCons2);
                                Lprenom1R8.setText(ReducCons3);
     
                                Prenom1Voy = StringToInt(ReducVoy1);
                                Prenom1Cons = StringToInt(ReducCons1);
     
                                Lprenom2.setText(strPrenom[1]);
                                reduction(strPrenom[1]);
                                Lprenom2R7.setText(ReducVoy3);
                                Lprenom2R5.setText(ReducVoy2);
                                Lprenom2R3.setText(ReducVoy1);
                                Lprenom2R1.setText(stockvoy);
                                //Lprenom2.setText(pre);
                                Lprenom2R2.setText(stockcons);
                                Lprenom2R4.setText(ReducCons1);
                                Lprenom2R6.setText(ReducCons2);
                                Lprenom2R8.setText(ReducCons3);
     
                                Lprenom3.setText(strPrenom[2]);
                                reduction(strPrenom[2]);
                                Lprenom3R7.setText(ReducVoy3);
                                Lprenom3R5.setText(ReducVoy2);
                                Lprenom3R3.setText(ReducVoy1);
                                Lprenom3R1.setText(stockvoy);
                                //Lprenom3.setText(pre);
                                Lprenom3R2.setText(stockcons);
                                Lprenom3R4.setText(ReducCons1);
                                Lprenom3R6.setText(ReducCons2);
                                Lprenom3R8.setText(ReducCons3);
     
                                Lprenom4.setText(strPrenom[3]);
                                reduction(strPrenom[3]);
                                Lprenom4R7.setText(ReducVoy3);
                                Lprenom4R5.setText(ReducVoy2);
                                Lprenom4R3.setText(ReducVoy1);
                                Lprenom4R1.setText(stockvoy);
                                //Lprenom4.setText(pre);
                                Lprenom4R2.setText(stockcons);
                                Lprenom4R4.setText(ReducCons1);
                                Lprenom4R6.setText(ReducCons2);
                                Lprenom4R8.setText(ReducCons3);
     
                                if (LnomR7.getText() != "") {
                                    if (Lprenom1R7.getText() == "")
                                        Lprenom1R7.setText(Lprenom1R5.getText());
                                    if (Lprenom2R7.getText() == "")
                                        Lprenom2R7.setText(Lprenom2R5.getText());
                                    if (Lprenom3R7.getText() == "")
                                        Lprenom3R7.setText(Lprenom3R5.getText());
                                    if (Lprenom4R7.getText() == "")
                                        Lprenom4R7.setText(Lprenom4R5.getText());
                                }
                                if (LnomR8.getText() != "") {
                                    if (Lprenom1R8.getText() == "")
                                        Lprenom1R8.setText(Lprenom1R6.getText());
                                    if (Lprenom2R8.getText() == "")
                                        Lprenom2R8.setText(Lprenom2R6.getText());
                                    if (Lprenom3R8.getText() == "")
                                        Lprenom3R8.setText(Lprenom3R6.getText());
                                    if (Lprenom4R8.getText() == "")
                                        Lprenom4R8.setText(Lprenom4R6.getText());
                                }
     
                                if (Lprenom1R7.getText() != "") {
                                    if (LnomR7.getText() == "")
                                        LnomR7.setText(LnomR5.getText());
                                    if (Lprenom2R7.getText() == "")
                                        Lprenom2R7.setText(Lprenom2R5.getText());
                                    if (Lprenom3R7.getText() == "")
                                        Lprenom3R7.setText(Lprenom3R5.getText());
                                    if (Lprenom4R7.getText() == "")
                                        Lprenom4R7.setText(Lprenom4R5.getText());
                                }
                                if (Lprenom1R8.getText() != "") {
                                    if (LnomR8.getText() == "")
                                        LnomR8.setText(LnomR6.getText());
                                    if (Lprenom2R8.getText() == "")
                                        Lprenom2R8.setText(Lprenom2R6.getText());
                                    if (Lprenom3R8.getText() == "")
                                        Lprenom3R8.setText(Lprenom3R6.getText());
                                    if (Lprenom4R8.getText() == "")
                                        Lprenom4R8.setText(Lprenom4R6.getText());
                                }
     
                                if (Lprenom2R7.getText() != "") {
                                    if (Lprenom1R7.getText() == "")
                                        Lprenom1R7.setText(Lprenom1R5.getText());
                                    if (LnomR7.getText() == "")
                                        LnomR7.setText(LnomR5.getText());
                                    if (Lprenom3R7.getText() == "")
                                        Lprenom3R7.setText(Lprenom3R5.getText());
                                    if (Lprenom4R7.getText() == "")
                                        Lprenom4R7.setText(Lprenom4R5.getText());
                                }
                                if (Lprenom2R8.getText() != "") {
                                    if (Lprenom1R8.getText() == "")
                                        Lprenom1R8.setText(Lprenom1R6.getText());
                                    if (LnomR8.getText() == "")
                                        LnomR8.setText(LnomR6.getText());
                                    if (Lprenom3R8.getText() == "")
                                        Lprenom3R8.setText(Lprenom3R6.getText());
                                    if (Lprenom4R8.getText() == "")
                                        Lprenom4R8.setText(Lprenom4R6.getText());
                                }
     
                                if (Lprenom3R7.getText() != "") {
                                    if (Lprenom1R7.getText() == "")
                                        Lprenom1R7.setText(Lprenom1R5.getText());
                                    if (Lprenom2R7.getText() == "")
                                        Lprenom2R7.setText(Lprenom2R5.getText());
                                    if (LnomR7.getText() == "")
                                        LnomR7.setText(LnomR5.getText());
                                    if (Lprenom4R7.getText() == "")
                                        Lprenom4R7.setText(Lprenom4R5.getText());
                                }
                                if (Lprenom3R8.getText() != "") {
                                    if (Lprenom1R8.getText() == "")
                                        Lprenom1R8.setText(Lprenom1R6.getText());
                                    if (Lprenom2R8.getText() == "")
                                        Lprenom2R8.setText(Lprenom2R6.getText());
                                    if (LnomR8.getText() == "")
                                        LnomR8.setText(LnomR6.getText());
                                    if (Lprenom4R8.getText() == "")
                                        Lprenom4R8.setText(Lprenom4R6.getText());
                                }
     
                                if (Lprenom4R7.getText() != "") {
                                    if (Lprenom1R7.getText() == "")
                                        Lprenom1R7.setText(Lprenom1R5.getText());
                                    if (Lprenom2R7.getText() == "")
                                        Lprenom2R7.setText(Lprenom2R5.getText());
                                    if (Lprenom3R7.getText() == "")
                                        Lprenom3R7.setText(Lprenom3R5.getText());
                                    if (LnomR7.getText() == "")
                                        LnomR7.setText(LnomR5.getText());
                                }
                                if (Lprenom4R8.getText() != "") {
                                    if (Lprenom1R8.getText() == "")
                                        Lprenom1R8.setText(Lprenom1R6.getText());
                                    if (Lprenom2R8.getText() == "")
                                        Lprenom2R8.setText(Lprenom2R6.getText());
                                    if (Lprenom3R8.getText() == "")
                                        Lprenom3R8.setText(Lprenom3R6.getText());
                                    if (LnomR8.getText() == "")
                                        LnomR8.setText(LnomR6.getText());
                                }
                                if (LnomR7.getText() != "" && Lprenom1R7.getText() != ""  && Lprenom2R7.getText() != "" && Lprenom3R7.getText() != "" && Lprenom4R7.getText() != "") {
                                    int resultat = StringToInt(LnomR7.getText()) + StringToInt(Lprenom1R7.getText()) + StringToInt(Lprenom2R7.getText()) + StringToInt(Lprenom3R7.getText()) + StringToInt(Lprenom4R7.getText());
                                    Ladd7.setText(IntToString(resultat));
                                }
     
                                Ladd5.setText(IntToString(AddVoy3));
                                Ladd3.setText(IntToString(AddVoy2));
                                Ladd1.setText(IntToString(AddVoy1));
                                Ladd.setText(IntToString(AddCons1 + AddVoy1));
                                Ladd2.setText(IntToString(AddCons1));
                                Ladd4.setText(IntToString(AddCons2));
                                Ladd6.setText(IntToString(AddCons3));
     
                                if (LnomR8.getText() != "" && Lprenom1R8.getText() != ""  && Lprenom2R8.getText() != "" && Lprenom3R8.getText() != "" && Lprenom4R8.getText() != "") {
                                    int resultat2 = StringToInt(LnomR8.getText()) + StringToInt(Lprenom1R8.getText()) + StringToInt(Lprenom2R8.getText()) + StringToInt(Lprenom3R8.getText()) + StringToInt(Lprenom4R8.getText());
                                    Ladd8.setText(IntToString(resultat2));
                                } 
                            } 
                        } 
                    }
                }  
            }
        }

  2. #2
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 111
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 111
    Par défaut
    je suppose que tu as deja fait tes 2 onglets avant qu'un click sur un radiobutton n'arrive.

    le probleme est la a mon avis :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    Structure_P1 wb = new Structure_P1();
    wb.BootFonct(obj.getText());
    tu fais un nouveau Structure_P1,qui n'est pas visible.
    tu dois utiliser celui qui existe deja.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut
    slt !!!!

    effectivement tous mes onglets sont créer au démarrage de l'applications mais tu dis que appeler 2 foix un constructeur de la même classe peut causer probléme et d'utiliser le même constructeur ...... je sais pas comment utiliser le même construteur car celui-ci ce trouve dans une autre classe qui est la classe TabbedPanes et sinon le faite de construire l'onglet avant et de donner des informations aprés pourquoi ne reconstruit-il pas ma classe avec les nouvelles donnée ????? il faut m'aider car la je comprend pas car mon projet et fini tout marche nickel je dois juste réglé ce probléme il me reste que la semaine prochaine pour finir car mon stage sera fini et ensuite examin donc si vous pouvez me diriger car la je sature ....... merci de votre aide

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut
    slt !!!!!

    personne à une petite idée ou une orientation car la j'ai tjs pas trouvé j'ai tout chanboulé le code et rien je séche ......... merci de votre aide

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut
    slt !!!!!!!

    même en utilisant le même constructeur rien nada ....... please help !!!!!

  6. #6
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 111
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 111
    Par défaut
    je ne te parle pas d'utiliser le même constructeur, mais d'utiliser le même OBJET.

    tu ne dois utiliser qu'un seul objet de classe : Structure_P1.


    en faisant : Structure_P1 wb = new Structure_P1();
    tu en fais un nouveau, hors tu n'en veux pas un nouveau tu veux celui qui est affiché, ce n'est pas pareil.

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut
    slt !!!!!!

    merci de ta reponse donc voila j'ai créer un constructeur da ma classe Structure_P1 dans la classe TaabedPanes la ou mes onglet sont créer .....

    Classe TabbedPanes ........

    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
    public class TabbedPanes extends JPanel{
     
        JTabbedPane tabbedPane = new JTabbedPane();
        public Structure_P1 pane2 = new Structure_P1();
     
        /** Creates a new instance of Main */
        public TabbedPanes() {
     
            super(new GridLayout(1, 1));
            initComponents();
     
        }
     
        private void initComponents()
        {
     
     
     
            //ImageIcon icon = createImageIcon("../images/middle.gif");
                     ImageIcon icon = createImageIcon("../images/entente_P1_P2.png");
                     ImageIcon icon2 = createImageIcon("../images/help-browser2.png");
                     ImageIcon icon3 = createImageIcon("../images/personne2.png");
                     ImageIcon icon5 = createImageIcon("../images/personne1.png");
                     ImageIcon icon4 = createImageIcon("../images/informations.png");
     
            informations pane = new informations();
            tabbedPane.addTab("Informations", icon4, pane.JS(),"Informations sur tous les Patients");
     
     
            tabbedPane.addTab("Structure_P1", icon5, pane2,"Structure Du premier Patient Selectionné");
     
            Structure_P2 pane3 = new Structure_P2();
            tabbedPane.addTab("Structure_P2", icon3, pane3,"Structure Du Deuxiéme Patient Selectionné");
     
            Composition_P1 pane4 = new Composition_P1();
            tabbedPane.addTab("Composition_P1", icon5, pane4.JS(),"Composition Du premier Patient Selectionné");
     
            Composition_P2 pane5 = new Composition_P2();
            tabbedPane.addTab("Composition_P2", icon3, pane5.JS(),"Composition Du Deuxiéme Patient Selectionné");
     
            Entente pane6 = new Entente();
            tabbedPane.addTab("Entente", icon, pane6.JS(),"Entente des deux patients selectionné");
     
            //JComponent panel4 = makeTextPanel("A Propos (has a preferred size of 410 x 50).");
            final HeadSpin pane7 = new HeadSpin();
            tabbedPane.addTab("A Propos", icon2, pane7,"A Propos du concepteur du programme et de la société");
            //tabbedPane.setMnemonicAt(0, KeyEvent.VK_F1);
     
            add(tabbedPane);
     
            tabbedPane.getModel().addChangeListener( 
     	   new ChangeListener() { 
     	      public void stateChanged(ChangeEvent e) { 
     		  SingleSelectionModel model = (SingleSelectionModel) e.getSource(); 
     		  if(model.getSelectedIndex() == tabbedPane.getTabCount()-1) { 
     
                          pane7.go();
     
     		  } 
     	      } 
     	   } 
     	); 
     
            tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     
        }
     
    //    private JComponent makeTextPanel(String text) {
    //        JPanel panel = new JPanel(false);
    //        JLabel filler = new JLabel(text);
    //        filler.setHorizontalAlignment(JLabel.CENTER);
    //        panel.setLayout(new GridLayout(1, 1));
    //        panel.add(filler);
    //        return panel;
    //    }
     
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String path) {
            java.net.URL imgURL = TabbedPanes.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
            }
        }
     
        /**
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event dispatch thread.
         */
        public static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Numerologie v1.0 béta <-- by --> Abdel BenMitnick");
            ImageIcon img = new ImageIcon(Toolkit.getDefaultToolkit().getImage("src/images/applications-internet.png"));
            frame.setIconImage(img.getImage());
            frame.setJMenuBar(jMenuBar());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
            //Create and set up the content pane.
            JComponent newContentPane = new TabbedPanes();
            newContentPane.setOpaque(false); //content panes must be opaque
            frame.getContentPane().add(new TabbedPanes(),BorderLayout.CENTER);
            frame.setBounds(200, 0, 1024, 780);
            frame.setVisible(true);
     
        }
     
        private static JMenuBar jMenuBar() {
            JMenuBar jMenuBar = new JMenuBar();
            jMenuBar.add(fileMenu());
            jMenuBar.add(editMenu());
            jMenuBar.add(helpMenu());
            return jMenuBar;
        }
     
        private static JMenu fileMenu() {
     
            JMenu fileMenu = new JMenu();
            fileMenu.setText("Fichier");
            fileMenu.add(nameMenuItem());
            fileMenu.add(exitMenuItem());
            return fileMenu;
        }
     
        public static JMenuItem nameMenuItem() {
     
            JMenuItem nameMenuItem = new JMenuItem();
            nameMenuItem.setText("Modifier Fiche Patient");
            nameMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    Therapeute_form re = new Therapeute_form();
                    re.setVisible(true);
                    re.setLocationRelativeTo(re.getParent());
                }
            });
            return nameMenuItem;
        }
     
        private static JMenu editMenu() {
     
            JMenu editMenu = new JMenu();
            editMenu.setText("Editer");
            return editMenu;
        }
     
        private static JMenu helpMenu() {
     
            JMenu helpMenu = new JMenu();
            helpMenu.setText("Aide");
            return helpMenu;
        }
     
        private static JMenuItem exitMenuItem() {
            JMenuItem exitMenuItem = new JMenuItem();
            exitMenuItem.setText("Sortir");
            exitMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(0);
                }
            });
            return exitMenuItem;
        }
     
    }

    Voici mes constructeurs de Ma classe Structure_P1 .........
    les commentaires du premier constructeur lorsque je les décommente il ce remplissent mais par contre lorsque je les commente et que je lance ma fonction BootFonct(); l'applie marche mais affichage rien .......


    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
    public Structure_P1()
        {
            super();
            JS();
    //        LNA.setText("8");
    //        LNA.setHorizontalAlignment(JLabel.CENTER);
    //        LAD.setText("6");
    //        LAD.setHorizontalAlignment(JLabel.CENTER);
    //        LCV.setText("22/4");
    //        LCV.setHorizontalAlignment(JLabel.CENTER);
    //        LES.setText("12/3");
    //        LES.setHorizontalAlignment(JLabel.CENTER);
    //        LES.setVerticalTextPosition(JLabel.TOP);
    //        LIS.setText("7");
    //        LIS.setHorizontalAlignment(JLabel.CENTER);
    //        LEXP.setHorizontalAlignment(JLabel.CENTER);
    //        LEXP.setText("5");
    //        LEXP2.setHorizontalAlignment(JLabel.CENTER);
    //        LEXP2.setText("158");
    //        LMI.setHorizontalAlignment(JLabel.CENTER);
    //        LMI.setText("14/5");
    //        LNF.setHorizontalAlignment(JLabel.CENTER);
    //        LNF.setText("22/4");
    //        Lprenom1.setHorizontalAlignment(JLabel.CENTER);
    //        Lprenom1.setText("Madeleine");
    //        Lprenom2.setHorizontalAlignment(JLabel.CENTER);
    //        Lprenom2.setText("Giselle");
    //        Lprenom3.setHorizontalAlignment(JLabel.CENTER);
    //        Lprenom3.setText("Beatrice");
    //        Lprenom4.setHorizontalAlignment(JLabel.CENTER);
    //        Lprenom4.setText("Morthelier");
    //        Lnom.setHorizontalAlignment(JLabel.CENTER);
    //        Lnom.setText("Caffin");
     
        }
     
        //public Structure_P1(String po)
        //{
        //    super();
        //    BootFonct(po);
        //}
     
        public void BootFonct(String op)
        {
                        //getJPanel();
            //informations qs = new informations();
            //System.out.println("Merde_" + po);
                        AfficheStructure(op);
                        AfficheVie();
                        AfficheIntime();
                        AfficheEXP();
                        AfficheInitSpirit();
                        AfficheNombAx();
                        AfficheArcDest();
                        AfficheNombForce();
    //                    AfficheInclusion(po);
    //                    AfficheIncluHolist();
                        AfficheElanSpirit();
     
        }
    Voici le code de mon JRadioButton de ma classe informations la ou le texte dois être récupérer ...........

    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
    private void getJrB(String[] t,String[] w) {
             a = 16;
            ButtonGroup group = new ButtonGroup();
            for (int i = 0;i < t.length && i<w.length;i++) {
                Pers1 += 1;
                 a += 22;
            final JRadioButton rb = new JRadioButton(t[i]);
            rb.setBounds(new Rectangle(5, a, 20, 23));
            rb.setName("Pers1_"+Pers1);
            rb.setText(w[i]);
            jPanel.add(rb);
            group.add(rb);
            jPanel.repaint();
            rb.addActionListener(new java.awt.event.ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                        if (e.getSource() instanceof JRadioButton) {
                            //ID = ((JRadioButton) e.getSource()).getText();
                            //tg.setText(ID);
                            TabbedPanes sd = new TabbedPanes();
                            sd.pane2.BootFonct(((JRadioButton) e.getSource()).getText());
                            //Structure_P1 wb = new Structure_P1("ID");
     
                        } else {
                                if (e.getSource() == jb) {
                                        System.out.println(ID);
                            } 
                        }
    //            public void itemStateChanged(ItemEvent e) {
    //               if (e.getStateChange() == ItemEvent.SELECTED) {
    //                JRadioButton obj = (JRadioButton)e.getItem();
    //                //JOptionPane.showMessageDialog(null,"type :"+obj.getText());
    //                ID = obj.getText();
    //                tg.setText(obj.getText());
    //                //Structure_P1 wb = new Structure_P1();
    //                //wb.BootFonct(obj.getText());
    //                //wb.revalidate();
    //                } 
    //                
    //            }
                 }
     
                 }
            );
     
            }
            a = 0;
        }
    par contre eclesia je pense avoir utiliser le même Objet comme tu dis si ce n'est pas le cas explique moi ........ merci de votre aide ......... a l'heure ou j'écrie je cherche tjs ........ thanks

  8. #8
    Rédacteur
    Avatar de eclesia
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    2 111
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 111
    Par défaut
    *est noyé dans le code*

    désolé mais je n'arrive pas a faire le lien entre les différents morceaux de codes que tu me montre.

    je vois plein d'appelle qui sortent de je ne sais où :
    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
     
            JS();
     
     
    AfficheStructure(op);
                        AfficheVie();
                        AfficheIntime();
                        AfficheEXP();
                        AfficheInitSpirit();
                        AfficheNombAx();
                        AfficheArcDest();
                        AfficheNombForce();
    //                    AfficheInclusion(po);
    //                    AfficheIncluHolist();
                        AfficheElanSpirit();
     
    ...etc...

    mais malgré tout ca je note toujours le même truc bizarre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    TabbedPanes sd = new TabbedPanes();
    sd.pane2.BootFonct(((JRadioButton) e.getSource()).getText());
    tu fais clairement un NOUVEAU TabbedPanes.

    tu dois recuperer le TabbedPanes qui est la :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    JComponent newContentPane = new TabbedPanes();
    *si j'ai bien suivit le problème*

    Mais honnetement (sans vouloir te vexer, ni me montrer desobligant) il y a trop d'appel de methodes qui viennent de nulle parts et d'autres "static".
    je me demande si c'est encore de l'objet?

    il faudrait peut etre revoir la structure de ton appli? non? (sans etre mechant)


    mais si quelqu'un d'autre veut bien essayer de te resoudre ton probleme, la je cale.

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    67
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 67
    Par défaut
    slt !!!!!!!

    merci de ta réponse ......... pour le code non tu n'est pas méchant tu constate c'est tout et oui je dois revoir mon code il à été chambouler car j'ai le probléme du JRadioButton que je n'ai tjs pas résolut ......... j'ai bien comprid se que tu voulais dire mais le probléme c'est que je ne suis pas arrivé à le faire ce que tu propose comme solution je suis nouveaux en Java ....... je vais voir si je peux comprendre ce que tu veux me faire comprendre .......... Merci de tes réponse et de ton aide ............

  10. #10
    Membre chevronné
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    429
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 429
    Par défaut
    Bonjour,

    Si tu as toujours ce problème, et si tu souhaites vraiment de l'aide, je te suggère de nous montrer un SSCCE.

    Sinon, cela va vraiment être difficile.

    Cordialement,

    Nicolas

Discussions similaires

  1. JTabbedPane et JPanel (avec scrollbar)
    Par Askle dans le forum Agents de placement/Fenêtres
    Réponses: 10
    Dernier message: 27/12/2009, 20h22
  2. Récupérer JPanel dans un JScrollPane dans un JTabbedPane
    Par orochimaru13 dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 16/05/2008, 11h02
  3. Superposition JPanel dans JTabbedPane
    Par rems033 dans le forum AWT/Swing
    Réponses: 9
    Dernier message: 23/06/2007, 13h13
  4. Réponses: 12
    Dernier message: 25/04/2007, 16h42
  5. Réponses: 1
    Dernier message: 29/11/2006, 03h20

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