Gradient problems in Java

后端 未结 5 767
滥情空心
滥情空心 2021-01-04 05:52

In my program I wanted to have a translucent white to transparent gradient on my JFrame to overlay a yellow background. This works fine and it needs to be a white to transpa

5条回答
  •  孤城傲影
    2021-01-04 05:56

    As Nick pointed out, the problem is that you are using transparent black rather than transparent white. So the translucent colours are a shade between white and black.

    Try replacing with this line in your code:

    GradientPaint pGradient = new GradientPaint(0, 0, new Color(255, 255, 255, iDegreeWhite), 0, getHeight(), new Color(255, 255, 255, iDegreeBlack));
    

提交回复
热议问题