Bonjour,

Commençant tout juste en programmation, j'ai créé un plateau de jeu avec JFrame et JPanel.

Je souhaite à présent afficher un rond dans une case de mon plateau (pour représenter un pion), mais bien sûr le rond ne s'affiche pas.



Voici ma classe représentant le Plateau voir => TEST AJOUT PION
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
 
 
 
// pan10 : case 21
	    gbc.gridx = 0;
	    gbc.gridy = 1;
	    gbc.gridwidth = 1;
	    gbc.gridheight = 1;
	    gbc.fill = GridBagConstraints.VERTICAL;
 
 
	    JLabel case21 = new JLabel ("21");
		JPanel pan10 = new JPanel();
		pan10.setBorder(BorderFactory.createMatteBorder(0,2,2,2, Color.BLACK));
		pan10.setPreferredSize(caseB);
 
 
		// TEST AJOUT PION 
 
		pan10.setLayout(new BorderLayout());					
		pan10.add(new Pion(), BorderLayout.WEST);	
 
 
		pan10.add(case21, BorderLayout.NORTH);
		pan1.add(pan10, gbc);

Ma classe représentant mon objet Pion :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
public class Pion extends JPanel {
 
 
	public void paintComponent(Graphics g){
	    System.out.println("Affichage du pion"); 
	    g.fillOval(50, 80, 10, 10);
	  }


Merci de votre aide !