0
我正試圖實現我自己的進度條。我有一個構造函數,那inits我的進度條和方法來繪製它:如何重繪字段?
protected void paint(Graphics graphics)
{
g = graphics; //remember graphics to redraw it later
ResizeImage r = new ResizeImage();
Picture = r.sizeImage(Picture, Width, Height);
graphics.drawBitmap(1, 1, Width, Height, Picture.getBitmap(), 0, 0); //dwaring background
Cursor = r.sizeImage(Cursor, Height, Height);
graphics.drawBitmap(1+(Width-Height*2)*Progress/(Maximum - Minimum), 1, Height, Height, Cursor.getBitmap(), 0, 0); //drawing cursor
}
因此,該類吸引我的進度條任何光標位置。既然如此,所有的作品都是完美的 我應該重繪我的進度條,設置光標到另一個位置的方法:
public void SetProgress (int p) {
Progress = p;
if (Progress<Minimum) Progress = Minimum;
if (Progress>Maximum) Progress = Maximum;
this.paint(g);
}
但它畫什麼。我錯過了什麼嗎? 如何重繪字段?