Bonjour,

J'aimerais afficher une fenêtre comprenant un JSplitPane.

Dans la partie supérieure du JSplitPane, il y a un champs texte dans lequel l'utilisateur entre un nombre. La partie inférieure du JSplitPane ne devant pas être visible au départ.
Puis, en fonction du nombre saisi par l'utilisateur, il faudrait que la partie inférieure du JSplitPane s'affiche avec à l'intérieur, autant de JComboBox que le nombre saisi par l'utilisateur.

Mon problème est que je n'arrive pas à faire apparaître la partie inférieure du JSplitPane, ou en tout cas, je n'arrive pas à retailler ma fenêtre principale pour afficher le contenu du JSplitPane.

Quelqu'un saurait-il ce qu'il faut que je fasse?

Un peu de code pour vous éclairer :
- mon construteur :
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
 
 
		setTitle("Configuration du tableau");
		setModal(true);
		setResizable(true);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
		getContentPane().setLayout(new BorderLayout());
 
		// subdivision of the window :
		// - top part <=> column number text field
		// - bottom part <=> columns caracteristics combo
		splitPaneVertical = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
		getContentPane().add(splitPaneVertical, BorderLayout.CENTER);
 
		// top part : column number text field
		JPanel colNumberPanel = new JPanel();
		splitPaneVertical.add(colNumberPanel, JSplitPane.LEFT);
 
		colNumberPanel.setSize(260, 35);
		colNumberPanel.setPreferredSize(new Dimension(260, 35));
		colNumberPanel.setLayout(new FlowLayout());
 
		JLabel label = new JLabel("Nombre de colonnes :");
		nbColumn = new JTextField();
		nbColumn.setSize(30, 20);
		nbColumn.setPreferredSize(new Dimension(30, 20));
		nbColumn.addKeyListener(new KeyListener() {
			public void keyPressed(KeyEvent arg0) {
				if (arg0.getKeyChar() == KeyEvent.VK_ENTER) {
					createCaracteristics();
					splitPaneVertical.add(colCaracteristicsPanel, JSplitPane.RIGHT);
					splitPaneVertical.repaint();
				}
			}
			public void keyReleased(KeyEvent arg0) {
			}
			public void keyTyped(KeyEvent arg0) {
			}
		});
		colNumberPanel.add(label);
		colNumberPanel.add(nbColumn);
 
		// bottom part : columns caracteristics combo
		colCaracteristicsPanel = new JPanel();
 
		// buttons
		JPanel buttonsPanel = new JPanel();
		getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
		buttonsPanel.setSize(300, 35);
		buttonsPanel.setPreferredSize(new Dimension(300, 35));
		buttonsPanel.setMaximumSize(new Dimension(300, 35));
		buttonsPanel.setLayout(new FlowLayout());
 
		JButton bOk = new JButton("OK");
		[...]
		JButton bCancel = new JButton("Cancel");
		[...]
		JButton bSave = new JButton("Save");
                                [...]
		buttonsPanel.add(bSave);
		buttonsPanel.add(bOk);
		buttonsPanel.add(bCancel);
 
 
		setLocation(CreateDefectTableDialog.getCenterPosition(this));
		this.pack();
- la méthode createCaracteristics() :
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
 
private void createCaracteristics() {
		int nb = new Integer(nbColumn.getText()).intValue();
		colCaracteristicsPanel.setLayout(new GridLayout(nb, 0, 5, 5));
		JLabel lab;
		JComboBox combo;
 
		for (int i = 0; i < nb; i++) {
			int cpt = i + 1;
			lab = new JLabel("Colonne " + cpt);
			combo = new JComboBox(carChoices);
			colCaracteristicsPanel.add(lab);
			colCaracteristicsPanel.add(combo);
		}
		this.repaint();
		this.pack();
	}
Merci d'avance!