我有这个paintComponent,我必须在其中绘制一个大小的圆,int size
因为它必须由setSmallCircle()
and更改setBigCircle()
。但我对java很陌生,我不知道如何做到这一点
到目前为止,我有这个:
public class ReactionPanel extends JPanel {
boolean setSmallCircle= false;
Color color = new Color (255,0,0); //color = red
Color c = new Color (255,255,0); //color = yellow
int size;
int x = 250;
int y = x;
public void paintComponent(Graphics g){
super.paintComponent(g);
if (setSmallCircle == true){
setSmallCircle(g);
}
else if(setSmallCircle==true){
setBigCircle(g);
}
}
void setSmallCircle(Graphics g, Color c){
size = 50;
g.setColor(c);
g.drawOval(x,y,size,size);
g.fillOval(x,y,size,size);
}
void setBigCircle(Graphics g, Color c){
size = 150;
g.setColor(c);
g.drawOval(x,y,size,size);
g.fillOval(x,y,size,size);
}
}
但它似乎没有编译。(错误setBigCircle(java.awt.Graphics,java.awt.Color) in ReactionExperiment.ReactionPanel cannot be applied to (java.awt.Graphics)
:)我做错了什么,我该如何解决?
哦,我还得打电话给重绘。我是在我的类 ReactionPanel 或其他地方的右括号之前这样做吗?
谢谢你的帮助!