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 only 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;
}