我有一个在JPanelu上绘制的功能,但不会改变我的颜色。始终显示白色方块。方法set.Color不起作用。
public void paint(Graphics g){
super.paint(g);
draw();
}
public void draw(){
Graphics g = map.getGraphics();
int xx = map.getSize().width;
int yy = map.getSize().height;
for(int i = 0; i < (first+second); i++){
if(i < first){
g.setColor( Color.red );
g.clearRect( (3*x+1)*(xx/x/3), (3*y+1)*(yy/y/3),(xx/x/3) , (yy/y/3) );
}else{
g.setColor(Color.black );
int j = i - first;
g.clearRect( (3*x+1)*(xx/x/3), (3*y+1)*(yy/y/3),(xx/x/3) , (yy/y/3) );
}
}
}