进度条颜色未根据值更新

时间:2016-03-08 09:04:20

标签: jquery jquery-ui

根据我们需要使用受尊重的颜色更新状态所需的进度百分比,我对进度条的要求很小。

我尝试使用下面的代码,但颜色没有得到更新。 这是代码,

class DrawingSpace extends JPanel{    
    private BufferedImage buf;   

    public DrawingSpace(){            
        //Initialization of variables and dimensions not shown
        buf = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
    }

    public void drawOnBuffer(){
        Graphics g2d = buf.createGraphics();
        g2d .setColor(Color.BLUE);    //draw the things you want
        g2d .fillOval(0,0,200,200);   //draw the things you want
        g2d .dispose();
    }
}

请与我分享您的想法

Fiddle

1 个答案:

答案 0 :(得分:2)

条件检查你做错了,就像下面那样,

if (progressPer >= 0 && progressPer <= 25) {
  $(".ui-widget-header").css("background", "red");
} else if (progressPer >= 26 && progressPer <= 75) {
  $(".ui-widget-header").css("background", "yellow");
} else if (progressPer >= 76 && progressPer <= 100) {
  $(".ui-widget-header").css("background", "green");
}

DEMO