Jlabel with alpha value

Posted by jouzef19 on Stack Overflow See other posts from Stack Overflow or by jouzef19
Published on 2010-06-02T22:32:36Z Indexed on 2010/06/02 22:34 UTC
Read the original article Hit count: 298

Filed under:
|

Hi: i have jLabel and i want to change its opacity (alpha value) each one second , i tried something like that but its not change each one second , jlable change its opacity with last alpha value .

  Color color = jLabel1.getBackground();
    int alpha = 255;
    long initTime = System.currentTimeMillis();
    while(true){
        if(System.currentTimeMillis() - initTime >= 1000){
        initTime = System.currentTimeMillis();
        alpha -=1;
        Color color2 = new Color(color.getRed(),color.getGreen(),color.getBlue(),alpha);
        jLabel1.setBackground(color2);

        }
        if(alpha<=0)
            break;
    }

© Stack Overflow or respective owner

Related posts about swing

Related posts about alpha