Bonjour,

Voila,lors du passage de la souris sur mes layer,l'ordre de ceux ci change.(plutot embetant pour mon effet)

Le code résumé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
        JLayeredPane pane = new JLayeredPane();
 
        foregroundColor = createColoredButton(
                (Color) GlobalProperties.getProp("color.foreground"),
                new Point(0,0));
 
        backgroundColor = createColoredButton(
                (Color) GlobalProperties.getProp("color.background"),
                new Point(10,10));
 
        pane.add(foregroundColor,0);
        pane.add(backgroundColor,1);
    }
Le code non résumé:
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
public class BackAndForegroundColorButtons extends JPanel implements ChangeListener{
    protected ColorButton foregroundColor;
    protected ColorButton backgroundColor;
 
    public BackAndForegroundColorButtons() {
        this.setLayout(new BorderLayout());
        this.setPreferredSize(new Dimension(30, 30));
 
        JLayeredPane pane = new JLayeredPane();
 
        foregroundColor = createColoredButton(
                (Color) GlobalProperties.getProp("color.foreground"),
                new Point(0,0));
        foregroundColor.addActionListener(new ChooseColorAction("color.foreground"));
        foregroundColor.setBorder(BorderFactory.createLineBorder(Color.black));
 
        backgroundColor = createColoredButton(
                (Color) GlobalProperties.getProp("color.background"),
                new Point(10,10));
        backgroundColor.addActionListener(new ChooseColorAction("color.background"));
        backgroundColor.setBorder(BorderFactory.createLineBorder(Color.black));
 
        pane.add(foregroundColor,0);
        pane.add(backgroundColor,1);
 
        this.add(pane,BorderLayout.CENTER);
 
        GlobalProperties.get().addChangeListener(this);
    }
 
    public void stateChanged(ChangeEvent e) {
        foregroundColor.setColor((Color) GlobalProperties.getProp("color.foreground"));
        backgroundColor.setColor((Color) GlobalProperties.getProp("color.background"));
    }
 
    private ColorButton createColoredButton(Color color,Point origin) {
        ColorButton button = new ColorButton(color);
        button.setBorder(BorderFactory.createLineBorder(Color.black));
        button.setBounds(origin.x, origin.y, 20, 20);
        return button;
    }

J'ai essayé de mettre les buttons en focusable(false) et chercher une methode dans la classe dictant ce comportement...rien n'y a fait.

Merci d'avance si vous avez une proposition.