Bonjour à tous,

Je suis sur un projet Java sur Eclipse et j'en suis à la IHM mais j'ai un souci.

Voici mon code
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
private Container buildContentPane() {
 
        JPanel panel = new JPanel(new GridLayout(0,2));
        panel.setBorder(new LineBorder(Color.BLACK, 2));
 
 
        JPanel reservation = new JPanel();
        reservation.setLayout(new BoxLayout(reservation,BoxLayout.X_AXIS));
        reservation.setBorder(new LineBorder(Color.BLUE, 2));
 
        JPanel liberation = new JPanel();
        liberation.setLayout(new BoxLayout(liberation,BoxLayout.X_AXIS));
        liberation.setBorder(new LineBorder(Color.BLUE, 2));
 
        reserve = new JButton("RESERVATION");
        reserve.setForeground(Color.BLUE);
        reserve.setFont(new Font("Calibri Bold",Font.ITALIC, 18));
        reserve.setAlignmentX(JButton.CENTER_ALIGNMENT);
        reserve.addActionListener(this);
        reservation.add(reserve);
Le problème est que je ne parviens pas à centrer mon bouton "reserve" dans mon BoxLayout.

Quelqu'un aurait-il la solution ?

Merci d'avance pour votre aide.