Salut à tous,

Je ne parviens pas à avoir de scrolling (automatique ou manuel) avec mon JTextArea. Pourtant celà fonctionnait avant que je le mette dans un GridBagLayout:

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
 
  private void makeComponents()
  {
	listener=new CommandSolverWin();
 
	area=new JTextArea();
	area.setEditable(false);
	JScrollPane sarea=new JScrollPane(area);
	sarea.setWheelScrollingEnabled(true);
	sarea.setAutoscrolls(true);
	sarea.setVerticalScrollBar(new JScrollBar());
	sarea.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
	area.setMaximumSize(new Dimension(100,100));
	area.setMinimumSize(new Dimension(100,100));
	area.setAutoscrolls(true);
	area.setBackground(Color.BLACK);
	area.setForeground(Color.WHITE);
	area.setText("");
 
	runstop=new Button("Run");
	runstop.setActionCommand("run");
	runstop.addActionListener(listener);
	addWindowListener(listener);
  }
  private void setComponentsToPane(Container pane)
  {
	pane.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
 
    c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 10;
	c.weighty = 0.95; 
	c.gridx = 0;
	c.gridy = 0;
	c.ipadx = 700;
	c.ipady = 500;
	c.gridwidth = 3;
	pane.add(area,c);
 
	c.weightx = 0.3;
	c.weighty = 0.05;
	c.gridx = 0;
	c.gridy = 1;
	c.ipadx = 210;
	c.ipady = 10;
	c.gridwidth = 1;
	pane.add(runstop, c);
 
	c.gridx = 1;
	c.gridy = 1;
	pane.add(new Button("Button 2"), c);
 
	c.gridx = 2;
	c.gridy = 1;
	pane.add(new Button("Button 3"), c);
  }
Quelqu'un a-t-il une idée ? Merci d'avance