j'ai créé une classe qui me dessine des cercles dans JPanel

est ce que C'est possible de récuperer le graphics de cette classe par une autre pour mieux comprendre 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 
 
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.Random;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
 
public class MonPanel extends JPanel 
{
	private int[][]adjascence;
	private int som,nba,n,m,m1,x=10,y=10,xx=25,yy=25;
	private Sommet TS,T;
	private CherSom CS;
	private Dessommet DS;
	private Listgraph LG=null,lg,teteG;
	private boolean iterX=false, iterY=false,stop=false;
	private Graphics g;
 
	MonPanel(int[][]adjascence1, int som1,int nba1)
	{
		adjascence=adjascence1;
		som=som1;
		nba=nba1;
		DS=new Dessommet();
		TS=DS.getListSommet();
		nba=DS.getnbsom();
		m=DS.getY();
		m1=DS.getX();
 
 
 
 
 
 
	}
    public void paintComponent(Graphics g1)
    {
 
    	  g=g1;
    	  super.paintComponent(g);
          setBounds(27, 38, 842,473);
          setBackground(Color.red);
 
 
    g.setFont(new Font("Tahoma",Font.BOLD,14));
      n=som;
      int a = 2;
      y=10;
      x=10;
      xx=15;
      yy=15;
      m=2;
    	  for(int i=0;i<som;i++)
    	  {
    		// Random q1=new Random();
    		// a =q1.nextInt(n)+1;
    		//  n--;
 
    		 // CS=new CherSom(TS,a);
    		 // TS=CS.getListS();
    		 //T=CS.getSupS();
 
    		  // La liste des cerles dessinés
 
 
    		  g.setColor(Color.white);
    		  g.drawString(Integer.toString(i),x,y);
 
 
    		  g.fillOval(x,y,xx,yy);
 
  			y=y+40;
  			if(iterX==false)
			{
				x=x+40;
				iterX=true;
			}
			else
			{
				x=x+15;
				iterX=false;
			}
 
  			if(x>820) {if(stop==false){ x=m*3; m=m+a; stop=true;a=a-1;}else {stop=false; x=m*4; m=m-3; a=a+2;} }
  			if(x<50) x=x+19;
  			if(y>440)
  			{
				if(iterY==false)
				{
					y=35;
					iterY=true;
				}
				else
				{
					y=10;
					iterY=false;
				}
 
 
				if(iterX==false)
				{
					x=x+40;
					iterX=true;
				}
				else
				{
					x=x+15;
					iterX=false;
				}
 
 
			}
 
 
 
 
    		  teteG=new Listgraph(x,y,xx,yy,lg);
    		  teteG.suiG=LG;
    		  LG=teteG;
    		 // T=TS;
 
    		 // TS=TS.suiS;
 
 
    	}
 
 
    }
    public Listgraph getLG()
    {
    	return this.teteG;
    }
    public Graphics getGr()
    {
    	return this.g;
    }
}

mon problèmec'est que quabd je récupere g par une autre classe et j'essaye de le modifier ça ne marche pas


merci