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 :

Elements qui bougent tout seuls


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2008
    Messages : 23
    Par défaut Elements qui bougent tout seuls
    Voila j'ai crée une fentre avec un chrono compte a rebourd dedans et donc les chiffres changent, mais en meme temps plusieurs autres élements comme ma JTextArea et ma JScrollPane ont eux aussi tendance a bouger. Ils se redimensionnent on dirait, jusqu'a arriver a une taille et arrete.

    Comment faire pour que ca ne se produisent pas?
    voici mon code de ma fenetre:
    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package org.qcm.projetInterface;
     
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.Collection;
    import java.util.Vector;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSeparator;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import org.jdesktop.layout.GroupLayout;
    import org.qcm.metier.Etudiant;
    import org.qcm.metier.Examen;
    import org.qcm.metier.Qcm;
    import org.qcm.metier.Question;
    import org.qcm.metier.Reponse;
    import org.qcm.metier.Reponse;
    import org.qcm.projetInterface.chrono;
     
    /**
     *
     * @author Silouane
     */
    public class examQcm extends JFrame {
     
     
        private chrono ch;
     
        private Etudiant et;
        private Qcm qcm;
        private Question quest;
        private Examen examen;
     
        private JPanel panel1=new JPanel();
        private JPanel panel2=new JPanel();
        private JPanel panel21=new JPanel();
        private JPanel panel22=new JPanel();
        private JPanel panel23=new JPanel();
        private JPanel panel3=new JPanel();
        private JPanel panel4=new JPanel();
        private JPanel panel5=new JPanel();
        private JPanel panel6=new JPanel();
     
        private JLabel qcmLabel;
        private JLabel description;
        private JLabel points;
        private JScrollPane scrollDesc;
        private JScrollPane scrollQuest;
        private JTextArea descText;
        private JLabel numQuest;
        private JTextArea question;
        private JScrollPane scrollPanel;
        private JButton valider;
     
        private JPanelReponses panelReponses; 
        private identification id;
        private EleveSession eS;
     
     
        public examQcm(identification id,EleveSession eS,Etudiant et,Qcm qcm,Question q,Examen examen){
            this.et=et;
            this.qcm=qcm;
            this.quest=q;
            this.examen=examen;
            this.eS=eS;
            this.id=id;
            initialComponent(eS,et,qcm,q,examen);
     
        }
     
        JPanelReponses getPanelReponse() {
            return panelReponses;
        }
     
        private void initialComponent(EleveSession eS,final Etudiant et, final Qcm qcm, final Question q, final Examen examen) {
            qcmLabel=new JLabel("QCM: "+qcm.getNom());
            description=new JLabel("Description: ");
            descText=new JTextArea(qcm.getDescription());
            descText.setEditable(false);
            descText.setLineWrap(true);
            descText.setWrapStyleWord(true);
            descText.setMinimumSize(new Dimension(300,50));
            descText.setMaximumSize(new Dimension(300,50));
            scrollDesc=new JScrollPane(descText);       
            numQuest=new JLabel("Question "+(qcm.getQuestions().indexOf(q)+1)+":");
            points=new JLabel("Points: "+q.getPts());
            question=new JTextArea(q.getQuestion());
            question.setWrapStyleWord(true);
            question.setLineWrap(true);
            question.setEditable(false);
            question.setBackground(Color.white);
            question.setMinimumSize(new Dimension(400,10));
            question.setMaximumSize(new Dimension(400,10));//voila ma TextArea qui bouge toute seule, j'ai essayé de la redimensionné mais rien a faire
            scrollQuest=new JScrollPane(question);
     
     
            BoxLayout    bl1=new BoxLayout(panel1,BoxLayout.Y_AXIS);
            panel1.setLayout(bl1);
     
     
            BoxLayout    bl2=new BoxLayout(panel2,BoxLayout.Y_AXIS);
            panel2.setLayout(bl2);
     
            GroupLayout gl21=new GroupLayout(panel21);
            panel21.setLayout(gl21);
     
            gl21.setHorizontalGroup(
                gl21.createParallelGroup(GroupLayout.LEADING)
                .add(gl21.createSequentialGroup()
                .add(0,0,40)
                    .add(qcmLabel)
                    .add(0,0,0)));
            gl21.setVerticalGroup(
                gl21.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(gl21.createSequentialGroup()
                    .add(0, 0, 0)
                    .add(gl21.createParallelGroup(GroupLayout.LEADING)))
                    .add(qcmLabel));
     
            //panelvide
            JPanel panelVide=new JPanel();
            GroupLayout panelVideLayout = new GroupLayout(panelVide);
            panelVide.setLayout(panelVideLayout);
            panelVideLayout.setHorizontalGroup(
                panelVideLayout.createParallelGroup(GroupLayout.LEADING)
                .add(0, 0, 20)
            );
            panelVideLayout.setVerticalGroup(
                panelVideLayout.createParallelGroup(GroupLayout.LEADING)
                .add(0, 0, 20)
            );
     
            //panelvide 2
            JPanel panelVide2=new JPanel();
            GroupLayout panelVideLayout2 = new GroupLayout(panelVide2);
            panelVide2.setLayout(panelVideLayout2);
            panelVideLayout2.setHorizontalGroup(
                panelVideLayout2.createParallelGroup(GroupLayout.LEADING)
                .add(0, 0, 20)
            );
            panelVideLayout2.setVerticalGroup(
                panelVideLayout2.createParallelGroup(GroupLayout.LEADING)
                .add(0, 0, 20)
            );
     
            GroupLayout gl22=new GroupLayout(panel22);
            panel22.setLayout(gl22);
     
            gl22.setHorizontalGroup(
                gl22.createParallelGroup(GroupLayout.LEADING)
                .add(gl22.createSequentialGroup()
                    .add(description)
                    .add(0,0,400)));
            gl22.setVerticalGroup(
                gl22.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(gl22.createSequentialGroup()
                    .add(0, 0, 0)
                    .add(gl22.createParallelGroup(GroupLayout.LEADING)))
                    .add(description));
     
            BoxLayout Blay=new BoxLayout(panel23,BoxLayout.Y_AXIS);
            panel23.setLayout(Blay);
     
     
     
            panel23.add(scrollDesc);
     
     
            panel2.add(panelVide);
            panel2.add(panel21);
            panel2.add(panelVide2);
            panel2.add(panel22);
            panel2.add(panel23);
            JSeparator sep=new JSeparator();
     
     
            GroupLayout gL3=new GroupLayout(panel3);
            panel3.setLayout(gL3);
     
            gL3.setHorizontalGroup(
                gL3.createParallelGroup(GroupLayout.LEADING)
                .add(gL3.createSequentialGroup()
                    .add(numQuest)
                    .add(0,0,350)
                    .add(points)));
     
            gL3.setVerticalGroup(
                gL3.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(gL3.createSequentialGroup()
                    .add(2, 2, 2)
                    .add(gL3.createParallelGroup(GroupLayout.LEADING)
                    .add(numQuest)
                    .add(points))));
     
     
            JPanel panel34=new JPanel();
            BoxLayout Blay1=new BoxLayout(panel34,BoxLayout.Y_AXIS);
            panel34.setLayout(Blay1);
     
            GroupLayout gL4=new GroupLayout(panel4);
            panel4.setLayout(gL4);
     
    //        scrollQuest.setMaximumSize(new Dimension(300,20));
     
            gL4.setHorizontalGroup(
                gL4.createParallelGroup(GroupLayout.LEADING)
                .add(gL4.createSequentialGroup()
                    .add(0,0,50)
                    .add(scrollQuest)
                    .add(0,0,50)));
     
            gL4.setVerticalGroup(
                gL4.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(gL4.createSequentialGroup()
                    .add(2, 2, 2)
                    .add(gL4.createParallelGroup(GroupLayout.LEADING)
                    .add(scrollQuest))));
     
            panel34.add(panel3);
            panel34.add(panel4);
     
            JScrollPane scrollPane3=new JScrollPane(panel34);
            scrollPane3.setMaximumSize(new Dimension(450,50));
            scrollPane3.setMinimumSize(new Dimension(450,50));
     
     
            BoxLayout Blay5=new BoxLayout(panel5,BoxLayout.Y_AXIS);
            panel5.setLayout(Blay5);
     
     
            panelReponses = new JPanelReponses(q);
            panel5.add(panelReponses);
            Vector<Reponse> choix = panelReponses.getChoix();
     
            scrollPanel=new JScrollPane(panel5);
     
     
            if(!qcm.getQuestions().lastElement().equals(q)){
                valider=new JButton(new ValiderQcmChoix(id,eS,this,et,qcm,q,examen,"Valider"));
            }
            else{valider=new JButton(new TerminerQcmChoix(id,eS,this,et,qcm,q,examen,"Terminer"));
     
            }
     
            ch=new chrono(id,eS,this,et,qcm,q,examen);//voila mon chrono
     
            GroupLayout gL6=new GroupLayout(panel6);
            panel6.setLayout(gL6);
     
            gL6.setHorizontalGroup(
                gL6.createParallelGroup(GroupLayout.LEADING)
                .add(gL6.createSequentialGroup()
                    .add(ch)
                    .add(0,0,450)
                    .add(valider)));
     
            gL6.setVerticalGroup(
                gL6.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(gL6.createSequentialGroup()
                    .add(2, 2, 2)
                    .add(gL6.createParallelGroup(GroupLayout.LEADING)
                    .add(ch)
                    .add(valider))));
     
            scrollPanel.setBackground(Color.WHITE);
            panel1.add(panel2);
            panel1.add(sep);
            panel1.add(scrollPane3);
            panel1.add(scrollPanel);
            panel1.add(panel6);
     
     
     
     
     
     
     
     
            add(panel1);
            setTitle(qcm.getNom());
            setSize(500,500);
            setResizable(false);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
            addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
            JOptionPane.showMessageDialog(null,"Vous ne pouvez pas quitter l'examen en cours, veuillez répondre aux questions et valider.","Action Impossible",JOptionPane.ERROR_MESSAGE);
           }
           });
     
        }
     
        public chrono getChrono(){
            return ch;
        }
     
     
    }

  2. #2
    Membre chevronné Avatar de ngpub
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    449
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 449
    Par défaut
    Généralement ce genre de problème est dû au LayoutManager qui réagit au changement de taille d'un élément. Ca peut être le cas ici mais ne connaissant pas le GroupLayout, je ne peux pas l'affirmer.

    Fixer la taille de l'élément qui bouge peut être une solution tout en sachant que la méthode réellement efficace est setPreferredSize(Dimention)

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2008
    Messages : 23
    Par défaut
    Oui tu as surement raison, mais preferedSize sur les élements qui bougent ca ne change rien. Une autre solution est possible?

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2008
    Messages : 23
    Par défaut
    Personne n'aurait une idée comment régler ce probleme?Svp j'ai beau essayer de regler les size de mes éléments, ils continuent de bouger.

  5. #5
    Membre chevronné Avatar de ngpub
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    449
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 449
    Par défaut
    Chez moi, en fixant la taille du composant le problème semble résolu.

    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
    // Solution 1
    question = new JTextArea(3, 16);
    question.setText(q.getQuestion());
    ...
    
    // Solution 2
    question=new JTextArea(q.getQuestion());
    question.setWrapStyleWord(true);
    question.setLineWrap(true);
    question.setEditable(false);
    question.setBackground(Color.white);
    question.setMinimumSize(new Dimension(400,10));
    question.setPreferredSize(new Dimension(400,10));
    question.setMaximumSize(new Dimension(400,10));
    scrollQuest=new JScrollPane(question);
    
    PS : ci-desous la classe modifiée qui m'a permis de faire le teste.
    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
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.text.SimpleDateFormat;
    import java.util.Collection;
    import java.util.Date;
    import java.util.Vector;
    import javax.swing.BoxLayout;
    import javax.swing.GroupLayout;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSeparator;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    //import org.jdesktop.layout.GroupLayout;
    //import org.qcm.metier.Etudiant;
    //import org.qcm.metier.Examen;
    //import org.qcm.metier.Qcm;
    //import org.qcm.metier.Question;
    //import org.qcm.metier.Reponse;
    //import org.qcm.metier.Reponse;
    //import org.qcm.projetInterface.chrono;
    import javax.swing.Timer;
     
    /**
     *
     * @author Silouane
     */
    public class examQcm extends JFrame {
        private static final long serialVersionUID = 1L;
     
    //    private chrono ch;
    //    
    //    private Etudiant et;
    //    private Qcm qcm;
    //    private Question quest;
    //    private Examen examen;
     
        private JPanel panel1=new JPanel();
        private JPanel panel2=new JPanel();
        private JPanel panel21=new JPanel();
        private JPanel panel22=new JPanel();
        private JPanel panel23=new JPanel();
        private JPanel panel3=new JPanel();
        private JPanel panel4=new JPanel();
        private JPanel panel5=new JPanel();
        private JPanel panel6=new JPanel();
     
        private JLabel qcmLabel;
        private JLabel description;
        private JLabel points;
        private JScrollPane scrollDesc;
        private JScrollPane scrollQuest;
        private JTextArea descText;
        private JLabel numQuest;
        private JTextArea question;
        private JScrollPane scrollPanel;
        private JButton valider;
     
        private JPanelReponses panelReponses; 
    //    private identification id;
    //    private EleveSession eS;
     
     
    //    public examQcm(identification id,EleveSession eS,Etudiant et,Qcm qcm,Question q,Examen examen){
    //        this.et=et;
    //        this.qcm=qcm;
    //        this.quest=q;
    //        this.examen=examen;
    //        this.eS=eS;
    //        this.id=id;
    //        initialComponent(eS,et,qcm,q,examen);
    //        
    //    }
     
        public examQcm(){
            initialComponent();
         }
     
        JPanelReponses getPanelReponse() {
            return panelReponses;
        }
     
    //    private void initialComponent(EleveSession eS,final Etudiant et, final Qcm qcm, final Question q, final Examen examen) {
        private void initialComponent() {
            qcmLabel=new JLabel("QCM: "+"qcm.getNom()");
            description=new JLabel("Description: ");
            descText=new JTextArea("qcm.getDescription()");
            descText.setEditable(false);
            descText.setLineWrap(true);
            descText.setWrapStyleWord(true);
            descText.setMinimumSize(new Dimension(300,50));
            descText.setMaximumSize(new Dimension(300,50));
            scrollDesc=new JScrollPane(descText);       
            numQuest=new JLabel("Question "+("qcm.getQuestions().indexOf(q)+1")+":");
            points=new JLabel("Points: "+"q.getPts()");
     
            question=new JTextArea(3, 16);//"q.getQuestion()");
            question.setWrapStyleWord(true);
            question.setLineWrap(true);
            question.setEditable(false);
            question.setBackground(Color.white);
    //        question.setMinimumSize(new Dimension(400,10));
    //        question.setPreferredSize(new Dimension(400,10));
    //        question.setMaximumSize(new Dimension(400,10));//voila ma TextArea qui bouge toute seule, j'ai essayé de la redimensionné mais rien a faire
            scrollQuest=new JScrollPane(question);
     
     
            BoxLayout    bl1=new BoxLayout(panel1,BoxLayout.Y_AXIS);
            panel1.setLayout(bl1);
     
     
            BoxLayout    bl2=new BoxLayout(panel2,BoxLayout.Y_AXIS);
            panel2.setLayout(bl2);
     
            GroupLayout gl21=new GroupLayout(panel21);
            panel21.setLayout(gl21);
     
            gl21.setHorizontalGroup(
                gl21.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gl21.createSequentialGroup()
                .addGap(0,0,40)
                    .addComponent(qcmLabel)
                    .addGap(0,0,0)));
            gl21.setVerticalGroup(
                gl21.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gl21.createSequentialGroup()
                    .addGap(0, 0, 0)
                    .addGroup(gl21.createParallelGroup(GroupLayout.Alignment.LEADING)))
                    .addComponent(qcmLabel));
     
            //panelvide
            JPanel panelVide=new JPanel();
            GroupLayout panelVideLayout = new GroupLayout(panelVide);
            panelVide.setLayout(panelVideLayout);
            panelVideLayout.setHorizontalGroup(
                panelVideLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGap(0, 0, 20)
            );
            panelVideLayout.setVerticalGroup(
                panelVideLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGap(0, 0, 20)
            );
     
            //panelvide 2
            JPanel panelVide2=new JPanel();
            GroupLayout panelVideLayout2 = new GroupLayout(panelVide2);
            panelVide2.setLayout(panelVideLayout2);
            panelVideLayout2.setHorizontalGroup(
                panelVideLayout2.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGap(0, 0, 20)
            );
            panelVideLayout2.setVerticalGroup(
                panelVideLayout2.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGap(0, 0, 20)
            );
     
            GroupLayout gl22=new GroupLayout(panel22);
            panel22.setLayout(gl22);
     
            gl22.setHorizontalGroup(
                gl22.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gl22.createSequentialGroup()
                    .addComponent(description)
                    .addGap(0,0,400)));
            gl22.setVerticalGroup(
                gl22.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gl22.createSequentialGroup()
                    .addGap(0, 0, 0)
                    .addGroup(gl22.createParallelGroup(GroupLayout.Alignment.LEADING)))
                    .addComponent(description));
     
            BoxLayout Blay=new BoxLayout(panel23,BoxLayout.Y_AXIS);
            panel23.setLayout(Blay);
     
     
     
            panel23.add(scrollDesc);
     
     
            panel2.add(panelVide);
            panel2.add(panel21);
            panel2.add(panelVide2);
            panel2.add(panel22);
            panel2.add(panel23);
            JSeparator sep=new JSeparator();
     
     
            GroupLayout gL3=new GroupLayout(panel3);
            panel3.setLayout(gL3);
            panel3.setBackground(Color.BLUE);
     
            gL3.setHorizontalGroup(
                gL3.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL3.createSequentialGroup()
                    .addComponent(numQuest)
                    .addGap(0,0,350)
                    .addComponent(points)));
     
            gL3.setVerticalGroup(
                gL3.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL3.createSequentialGroup()
                    .addGap(2, 2, 2)
                    .addGroup(gL3.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(numQuest)
                    .addComponent(points))));
     
     
            JPanel panel34=new JPanel();
            panel34.setBackground(Color.GREEN);
            BoxLayout Blay1=new BoxLayout(panel34,BoxLayout.Y_AXIS);
            panel34.setLayout(Blay1);
     
            GroupLayout gL4 = new GroupLayout(panel4);
            panel4.setBackground(Color.CYAN);
            panel4.setLayout(gL4);
     
    //        scrollQuest.setMaximumSize(new Dimension(300,20));
     
            gL4.setHorizontalGroup(
                gL4.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL4.createSequentialGroup()
                    .addGap(0,0,50)
                    .addComponent(scrollQuest)// question scrollQuest -------------------------------------------------------------
                    .addGap(0,0,50)));
     
            gL4.setVerticalGroup(
                gL4.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL4.createSequentialGroup()
                    .addGap(2, 2, 2)
                    .addGroup(gL4.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(scrollQuest))));
     
            panel34.add(panel3);
            panel34.add(panel4);
     
            JScrollPane scrollPane3=new JScrollPane(panel34);
            scrollPane3.setMaximumSize(new Dimension(450,50));
            scrollPane3.setMinimumSize(new Dimension(450,50));
     
     
            BoxLayout Blay5=new BoxLayout(panel5,BoxLayout.Y_AXIS);
            panel5.setLayout(Blay5);
     
     
            panelReponses = new JPanelReponses();
            panel5.add(panelReponses);
     //       Vector<Reponse> choix = panelReponses.getChoix();
     
            scrollPanel=new JScrollPane(panel5);
     
     
    //        if(!qcm.getQuestions().lastElement().equals(q)){
    //            valider=new JButton(new ValiderQcmChoix(id,eS,this,et,qcm,q,examen,"Valider"));
    //        }
    //        else{
    //        	valider=new JButton(new TerminerQcmChoix(id,eS,this,et,qcm,q,examen,"Terminer"));
    //        }
            valider=new JButton("Terminer");
     //       ch=new chrono(id,eS,this,et,qcm,q,examen);//voila mon chrono
            chrono ch=new chrono();//voila mon chrono
     
     
     
            GroupLayout gL6=new GroupLayout(panel6);
            panel6.setLayout(gL6);
     
            gL6.setHorizontalGroup(
                gL6.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL6.createSequentialGroup()
                    .addComponent(ch)
                    .addGap(0,0,450)
                    .addComponent(valider)));
     
            gL6.setVerticalGroup(
                gL6.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(gL6.createSequentialGroup()
                    .addGap(2, 2, 2)
                    .addGroup(gL6.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(ch)
                    .addComponent(valider))));
     
            scrollPanel.setBackground(Color.WHITE);
            panel1.add(panel2);
            panel1.add(sep);
            panel1.add(scrollPane3);
            panel1.add(scrollPanel);
            panel1.add(panel6);
     
     
     
     
     
     
     
     
            add(panel1);
            setTitle("qcm.getNom()");
            setSize(500,500);
            setResizable(true);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
    //        addWindowListener(new WindowAdapter(){
    //        public void windowClosing(WindowEvent e){
    //        JOptionPane.showMessageDialog(null,"Vous ne pouvez pas quitter l'examen en cours, veuillez répondre aux questions et valider.","Action Impossible",JOptionPane.ERROR_MESSAGE);
    //       }
    //       });
     
        }
     
    //    public chrono getChrono(){
    //        return ch;
    //    }
     
        public static void main(String[] args) {
        	new examQcm().setVisible(true);
        }
     
     
    }
     
     
     
    class chrono extends JLabel {
    	private static final long serialVersionUID = 1L;
     
    	public chrono() {
    		setBackground(Color.RED);
    		setOpaque(true);
    		new Timer(1000, new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				setText(new Date().toString());
    				repaint();
    			}
    		}).start();
    	}
    }
     
    class JPanelReponses extends JPanel {
    	private static final long serialVersionUID = 1L;
     
    	public JPanelReponses() {
    		setPreferredSize(new Dimension(160, 120));
    		setBackground(Color.YELLOW);
    	}
    }

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2008
    Messages : 23
    Par défaut
    Merci tout d'abord pour ton aide.

    Très étrange, car j'ai fais les deux modifications que tu me proposes et j'ai toujours le même soucis.
    Ma JTextArea qui se redimenssionne, peut etre faut il que je setPreferedSize du panel qui la contient et du JScrollPane aussi. Je ne sais que faire

    J'ai un un label qui ne cesse d'etre modifié c'est pour ca que ma fenetre bouge toute seule

Discussions similaires

  1. Réponses: 3
    Dernier message: 19/11/2014, 14h40
  2. [Swing] JPanel avec sa JScrollBar qui scrolle toute seule
    Par chcoust dans le forum AWT/Swing
    Réponses: 5
    Dernier message: 22/11/2006, 14h37
  3. pc portable qui reboot tout seul
    Par pepper18 dans le forum Windows XP
    Réponses: 23
    Dernier message: 24/06/2006, 14h51
  4. [MFC] un CDialog qui disparait tout seul.
    Par tut dans le forum MFC
    Réponses: 4
    Dernier message: 21/06/2006, 14h01
  5. Ip qui change toute seul , je veux stoper..?
    Par loobstyle dans le forum Windows XP
    Réponses: 2
    Dernier message: 19/06/2006, 08h25

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