lu,

Je souhaite personnaliser la scrollbar d'un JScrollPane. (La couleur surtout)
Hors en faisant des test je m'aperçois que cela ne fonctionne pas : la barre de défilement est toujours grise ainsi que les boutons.
Si quelqu'un trouve d'ou vient mon erreur

Merci
@+


==========================================

Mon test :



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
 
 
 
import javax.swing.*;
import java.awt.*;
 
 
public class Test extends JFrame{
    Container EcranDemarrage;
    public Test () {
 
        LookETFeel Apparence = new LookETFeel();//Apparence des composants
 
        EcranDemarrage = this.getContentPane();
 
        JPanel GPanel= new JPanel();
        GPanel.setBackground(Color.orange);
        GPanel.setLayout(new GridLayout(0, 2, 30, 20));
 
        for (int i=0;i<10;i++){
            JButton ooo = new JButton();
            ooo.setText("ooo");
            GPanel.add(ooo);
        }
 
        JScrollPane GscrollPane = new JScrollPane(GPanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        GscrollPane.setPreferredSize(new Dimension(200, 100));
        EcranDemarrage.add(GscrollPane);
 
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.pack();
 
    }
 
    public static void main(String[] args) {
        Test tete = new Test();
        Test .setVisible(true);
    }
}



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
 
import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
 
 
public class LookETFeel {
    public LookETFeel() {
 
        try {
            UIManager.setLookAndFeel("UIManager.getCrossPlatformLookAndFeelClassName()");
        } catch (Exception e) {
            System.out.println("Error : " + e);
        }
 
        UIManager.put("scrollbar", new ColorUIResource(255, 0, 0)); 
        UIManager.put("ScrollBar.highlight", new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.shadow", new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.arrowColor", new ColorUIResource(100, 100, 0));
 
        UIManager.put("ScrollBar.thumb", new ColorUIResource(50, 50, 0)); 
        UIManager.put("ScrollBar.thumbDarkShadow",new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.thumbHighlight",new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(100, 100, 0)); 
 
        UIManager.put("ScrollBar.track", new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.trackForeground",new ColorUIResource(100, 100, 0)); 
        UIManager.put("ScrollBar.trackHighlight", new ColorUIResource(255, 0, 0));
        UIManager.put("ScrollBar.trackHighlightForeground", new ColorUIResource(255, 0, 0));
 
        UIManager.put("ScrollBar.width", new Integer(15));
        UIManager.put("ScrollBar.background", new ColorUIResource(100,100,0));
        UIManager.put("ScrollBar.foreground", new ColorUIResource(0,0,0));
 
 
 
 
 
 
    }
}