Salut à tous,
Je pense que je ne dois pas tout comprendre au sujet des JScrollPane...
En effet, je veux afficher sur une JFrame un JScrollPane contenant lui même un JPanel de taille plus grande que la JFrame et qui contient lui même (en Grid Layout ) 2 graphes héritants de JPanel...
Je ne sais si je suis assez clair mais je vous laisse qques bouts de code avec pour que ce soit plus clair!
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
 
package LeesaVib;
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
 
public class FenetreTest extends JFrame
{
    private JGraph2D[] graph ;
    private JPanel panelGeneral ;
    private JScrollPane scrollPane ;
 
    public FenetreTest() 
    {
        super();
 
        build();
    }
 
    public void build()
    {
 
 
        this.graph = new JGraph2D[2];
 
        this.panelGeneral = new JPanel() ;
        this.panelGeneral.setBounds(0,0,1000,1000);
        this.panelGeneral.setLayout(new GridLayout(2,1));
 
        // On ajoute les composants a la fenetre
        this.graph[0] = new JGraph2D(1000,300,0);
        this.graph[1] = new JGraph2D(1000,300,0);
        this.panelGeneral.add(this.graph[0]);
        this.panelGeneral.add(this.graph[1]);
 
        this.scrollPane = new JScrollPane(this.panelGeneral,scrollPane.VERTICAL_SCROLLBAR_ALWAYS, scrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        this.scrollPane.setBounds(0,0,480,480);
 
        this.scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener()
        {
            public void adjustmentValueChanged(AdjustmentEvent e)
            {
                repaint();
            }
        });
 
        this.scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener()
        {
            public void adjustmentValueChanged(AdjustmentEvent e)
            {
                repaint();
            }
        });
 
        //this.scrollPane.setViewportView(this.panelGeneral);
        this.add(this.scrollPane);
 
        // On definit les attributs de la fenetre
        this.setSize(500,500);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
        this.setVisible(true);
    }
 
}
Je vous remercie d'avance pour votre aide!