简体   繁体   中英

Clear JFrame background on transparent window

i have a transparent JFrame AWTUtilities.setWindowOpaque(this, false); I have a problem when resizing the window. I need something that could clear the background of the window before drawing on it,I need to make it all the background empty and transparent. Now the painting is draw over the old background and looks ugly. I tried to draw a transparent image over the background but i have same issues.

If you have an opaque component you're completely responsible for drawing its content. The windowing system or AWT does NOTHING to set the background to some defined state.

So at least you should do something like the basic Canvas code

        g.clearRect(0, 0, width, height);

What exactly do you mean with "transparent". Do you want to look through to the desktop? Do you want to see panel behind your component (then at least it should not be "opaque").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM