I am developing application based on Swing.
My problem is I use JWebBrowser and I put one in a scrollable panel. When I scroll down the panel the web browser overlaps the panel/frame of the application.
What can I do so the browser does not overlap the panel?
I don’t see an answer here, so as someone who has been down this bumpy road, I can sympathize with these issues and would like provide some guidance.
First of all, the
JWebBrowseris an AWT heavyweight component, and does not play nicely in Swing (since it uses lightweight components) without some intervention.Instantiate
JWebBrowserlike this for the first step of friendly Swing integration:That instantiation alone should prevent the browser from overlapping the Swing lightweight components, however, it will not work as you would expect with transparencies or layers unless you do some additional steps.
So, during construction, call these:
And then, right before the web browser is to be used with any kind of transparency or layers, call these:
Those calls will repaint the backbuffer right before the component is to be used and so when being used, it will be displayed with that most recent backbuffer and will look pretty much like a regular Swing component at that point.
There are some nuances with all of this, but that’s the basics and should be enough to get anyone started with it.