Bonjour,

J'ai un JPanel avec une JList dedans et suivant la sélection dans la liste, je veux afficher un autre JPanel.
J'ai donc implémenté une Classe JPanel avec une sous-classe pour le 2ème JPanel.
Mais malheureusement, j'ai beau faire validate(); ou validatetree(); celui-ci refuse obstinément de s'afficher...
Voici mon 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
 
public class FormatManager 	extends JPanel 
								implements ListSelectionListener {
 
	private JList<String> list;
	EditGroup editGroup;
 
	class EditGroup extends JPanel {
 
		public EditGroup() {
 
			TitledBorder border = BorderFactory.createTitledBorder(
	        		BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Editer le format");
			this.setBorder(border);
			this.setBounds(190, 63, 320, 450);
			this.setLayout(null);
 
			JLabel lbl1=new JLabel("Version :");
			lbl1.setBounds(10, 20, 50, 20);
			JTextField txtVersion = new JTextField();
			txtVersion.setBounds(70, 20, 50, 20);
 
			this.add(txtVersion);
			this.add(lbl1);
			this.setOpaque(false);
 
		}
	}
 
	@Override
	public void valueChanged(ListSelectionEvent e) {
		// List selection changed
		if (e.getValueIsAdjusting() == false) {
 
			Integer i = list.getSelectedIndex();
 
			if(i==-1){
				// No selection
 
			} else {
 
				this.editGroup = new EditGroup();
				this.editGroup.setVisible(true);
				this.editGroup.validate();
				this.add(editGroup);
				this.validate();
				this.validateTree();
 
			}
		}
 
	}
 
	...
 
	public FormatManager() {
 
		this.setLayout(null);
 
		ImageIcon icon = new ImageIcon("images/logo_NB_transp.png");
		JLabel fond = new JLabel(icon,JLabel.CENTER);
		fond.setBounds(10,10,500,500);
		JLabel title = new JLabel("Gestion des formats",JLabel.CENTER);
		title.setFont(title.getFont().deriveFont(new Float(20)));
		title.setBounds(10, 10, 520, 30);
		JLabel label1 = new JLabel("Liste des formats",JLabel.CENTER);
		label1.setBounds(10, 40, 150, 20);
		JLabel label2 = new JLabel("Editer le format",JLabel.CENTER);
		label2.setBounds(300, 40, 100, 20);
 
		DefaultListModel<String> listModel = this.getListOfFormat();
		list = new JList<String>(listModel);
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 
		list.addListSelectionListener(this);
		JScrollPane listScrollPane = new JScrollPane(list);
		listScrollPane.setBounds(10, 70, 160, 300);
 
		this.add(listScrollPane);
		this.add(label2);
		this.add(label1);
		this.add(title);
		this.add(fond);
 
	}
 
}
Quelqu'un a une idée ?