Transparent JFrame background

后端 未结 5 864
温柔的废话
温柔的废话 2021-02-15 16:31

Is it possible to make a JFrame that has a transparent background and draw an image on it, so only the image will be visible with no border or background?

5条回答
  •  遥遥无期
    2021-02-15 16:58

    Yes, it's possible in many ways. This is one of them:

    setUndecorated(true);
    setBackground(new Color(1.0f,1.0f,1.0f,0.5f));
    

    4th float (which I set to 0.5f) in Color's constructor is alpha channel. It can be 0.0f - 1.0f depend on transparency you want.

提交回复
热议问题