j'ai créé un ptit programme ou je devrais trouver dans ma frame un JScrollPane qui contient un container.

Mais le pb c que je n arrive pas a mettre mon container dans ma JScrollPane

voici le code un peu pourrit!!!!!

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
 
import java.awt.*;
import javax.swing.*;
 
class test extends JFrame
{
 
	public test()
	{
this.setDefaultCloseOperation(test.EXIT_ON_CLOSE);
Container interieur2 = this.getContentPane();
GridBagLayout repartiteur = new GridBagLayout();
GridBagConstraints contraintes;	
JScrollPane ascenseur;        	
ascenseur=new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
interieur2.add(ascenseur);
interieur2.setLayout(repartiteur);
 
	JLabel Titre01=new JLabel("hello");		
	contraintes = new GridBagConstraints();
	contraintes.gridx = 0;
	contraintes.gridy = 0;
	Titre01.setPreferredSize(new Dimension(80, 15));
	Titre01.setMaximumSize(new Dimension(80, 15));
	Titre01.setMinimumSize(new Dimension(80, 15));
	contraintes.fill = GridBagConstraints.CENTER;
	repartiteur.setConstraints(Titre01, contraintes);
	interieur2.add(Titre01);	
 
	JTextField texteresultat31 = new JTextField("case rose");
	contraintes = new GridBagConstraints();
	contraintes.gridx = 0;
	contraintes.gridy = 1;
	texteresultat31.setPreferredSize(new Dimension(1200,20));
	texteresultat31.setMaximumSize(new Dimension(1200, 20));
	texteresultat31.setMinimumSize(new Dimension(1200,20));
	texteresultat31.setEditable(false);
	texteresultat31.setBackground(Color.pink);
	contraintes.anchor = GridBagConstraints.WEST;
	repartiteur.setConstraints(texteresultat31, contraintes);
	interieur2.add(texteresultat31);
	}
public static void main(String [] args)
  {
// Création 
    test ext = new test();
	ext.setSize(1200, 1200);//dimension de la fenetre
	ext.setVisible(true);// Affichage de la vue
  }
}