Java setting background from JAR and making it transparent

后端 未结 2 1803
醉梦人生
醉梦人生 2021-01-14 17:17

Be patient I\'m still a beginner, no rude comments please.

So the goal of this question is so I learn how to set the background of my already transparent JFrame to b

2条回答
  •  独厮守ぢ
    2021-01-14 17:59

    My first guess in "SystemInfo/black.png" can't be referenced as File because it's an embedded/internal resource, residing within your application Jar.

    In order to read it (via ImageIO) you will need to use something more like...

    ImageIO.read(getClass().getResource("SystemInfo/black.png"))
    

    Instead.

    Secondly, blurring the image probably won't result in the effect you are looking for, as it won't have any effect of the how the content behind your window is actually painted.

    Instead, you will need to capture the section of the screen below your window and blur that.

    You can achieve this by using Robot, but will need to make the window invisible when you grab the screen shot.

    It will also not be a "live" update.

提交回复
热议问题