bonjour a tous,


voila jessaye d'avoir un jpanel bleu ciel tout a gauche (sur toute la hauteur de la page) et un jpanel blanc a droite avec lui aussi toute la hauteur de la page et la largeur restante.
J'ai eu beau essayer de jouer avec les differents layout, je n'arrive pas au resultat voulu.

Et je souhaite que dans le jpanel bleu ciel, des boutons bleu marine soient affiches mais pas colles les uns aux autres: indent a gauche du jpanel, indent a droite du jpanel et espacement entre les boutons d'au moins 75.

je transmets mon code, peut etre quelquun pourra t'il m'aider?


import javax.swing.*;
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JFrame;


public class MaDemo extends JFrame{

public MaDemo(){

Color bckColor = new Color(51,153,255);
Color butColor = new Color(0,0,153);

JButton b1 = new JButton("B1");
JButton b2 = new JButton("B2");
JButton b3 = new JButton("B3");
JButton b4 = new JButton("B4");

b1.setForeground(Color.white);
b1.setBackground(butColor);
b2.setForeground(Color.white);
b2.setBackground(butColor);
b3.setForeground(Color.white);
b3.setBackground(butColor);
b4.setForeground(Color.white);
b4.setBackground(butColor);

b1.setSize(new Dimension(100, 100));
b2.setSize(new Dimension(100, 100));
b3.setSize(new Dimension(100, 100));
b4.setSize(new Dimension(100, 100));

JPanel p_training_left = new JPanel();
JPanel p_training_right = new JPanel();
JPanel p_global = new JPanel();
JPanel p_test = new JPanel();

p_training_left.setPreferredSize(new Dimension(200, 1200));
p_training_left.setMinimumSize(new Dimension(200, 1200));
p_training_left.setMaximumSize(new Dimension(200, 1200));
p_training_right.setMinimumSize(new Dimension(this.getContentPane().getWidth()-p_training_left.getWidth(), 1200));
p_training_right.setMinimumSize(new Dimension(this.getContentPane().getWidth()-p_training_left.getWidth(), 1200));
//p_training_left.setMaximumSize(new Dimension(250, 150)); // hardCoded sizing
p_training_left.setBackground(bckColor);
p_training_right.setBackground(Color.red);
//FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
//GridLayout c2 = new GridLayout(0,2);
//this.getContentPane().setLayout(flow);
p_training_left.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 4;
c.gridx = 2;
c.gridy = 2;
p_training_left.add(b1, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 4;
c.gridx = 2;
c.gridy = 4;
p_training_left.add(b2, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 4;
c.gridx = 2;
c.gridy = 6;
p_training_left.add(b3, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 4;
c.gridx = 2;
c.gridy = 8;
p_training_left.add(b4, c);

p_global.setLayout(new GridBagLayout());
GridBagConstraints c4 = new GridBagConstraints();
c4.fill = GridBagConstraints.HORIZONTAL;
c4.anchor = GridBagConstraints.FIRST_LINE_START;
p_global.add(p_training_left, c4);
p_global.add(p_training_right, c4);
//p_global.setLocation(150, 150);
//this.getContentPane().add(p_global, GridBagLayout.FIRST_LINE_START);
this.getContentPane().add(p_global);
this.pack();




}//end constructor

public static void main(String[] args){
MaDemo md = new MaDemo();
md.setSize(1000,800);

// make the frame half the height and width
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
md.setLocation(dim.width/2-md.getSize().width/2, dim.height/2-md.getSize().height/2);
//md.setVisible(true);
//md.setUndecorated(true);
md.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
//md.setVisible(true);
md.show();

}//end main

}//end public class

class ImagePanel extends JPanel {

private Image img;

public ImagePanel(String img) {
this(new ImageIcon(img).getImage());
}

public ImagePanel(Image img) {
this.img = img;
Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
}

public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, null);
}

}

Je vous remercie d'avance!
Et Joyeuses fetes!