JBs | Peut être serait-il plus simple d'utilise des sous panels ... Enfin du moins c'est quelque chose que j'ai essayé aussi mais j'arrive une fois de plus à un résultat qui n'est pas extra : si je redimensionne ma fenetre, tous les éléments bougent avec, se recentrent au lieu de rester strictement alignés a gauche ... Enfin bref, pas gégé. Si quelqu'un pouvait m'indiquer comment faire pour les docker de maniere définitive et indépendante du redimensionnement de ma fenetre, je suis preneur !
J'ai aussi le probleme du second panel qui s'affiche uniquement de maniere centrée ...
Voila le code :
Code :
- public MCQ_Editing(String id)
- {
- gbc = new GridBagConstraints();
- super.setLayout(new GridBagLayout());
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.EAST;
- super.id = id;
- answers = new Vector();
-
- UpperPane = new JPanel();
- QuestionPane = new JPanel();
-
- //Config. of the Upper Panel
- UpperPane.setLayout(new GridLayout(3,1));
- UpperPane.setPreferredSize(new Dimension(600,60));
- UpperPane.add(label);
- UpperPane.add(text);
- UpperPane.add(answerlabel);
- super.add(UpperPane, gbc);
-
- //Config. of the Middle Panel (Questions)
- QuestionPane.setLayout(new GridBagLayout());
- QuestionPane.setPreferredSize(new Dimension(600,350));
- QuestionPane.setAlignmentX(0);
- QuestionPane.setAlignmentY(0);
-
- gbd = new GridBagConstraints();
- gbd.gridx = 0;
- gbd.gridy = 0;
- gbd.fill = GridBagConstraints.HORIZONTAL;
- gbd.anchor = GridBagConstraints.EAST;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.gridy++;
- super.add(QuestionPane, gbc);
-
-
-
- }
- public void addAnswer(String id, String text, int num_quest) {
- CheckBox toAdd = new CheckBox(id, text);
- answers.add(toAdd);
- gbd.gridy++;
- QuestionPane.add(new JLabel(num_quest+". " ), gbd);
- gbd.gridx++;
- QuestionPane.add(toAdd, gbd);
- gbd.gridx = 0;
- }
|
Voila ce que j'obtiens (sans redimensionnement de fenetre)
Avec un redimensionnement :
PS : je suis assez novice en java  |