Transparent JEditorPane in JScrollPane on JPanel Background

If I move the JScrollPane so that it is in front and partially covers the JPanel, then the JEditorPane inside the JScrollPane has paint problems. He's redrawing the JPanel background incorrectly. Therefore, when scrolling, you get into problems with the picture.

I tried overlapping using the following methods - JScrollPane inside JPanel - JScrollPane partially closes JPanel using FreeLayout (Builder Builder NetBeans) - JScrollPane partially closes JPanel using JLayeredPane

JPanel has a solid background right now, but I will continue it to have a gradient as soon as I get a solid background for work.

How can I get JEditorPane to introduce cropped background from JPanel?

I make it transparent using jEditorPane.setBackground(new Color(0,0,0,0))

I tried using setOpaque(false) , as you would for a panel, but it is like returning the default background if you do this with JEditorPane.

Original question from the employee: https://stackoverflow.com/questions/6364460/jframe-screen-paint-issues-when-using-transparency

The original question was not well written and did not seem to give good answers.

Answers to a question from a colleague in a proposal:

  • "Try with setOpaque (false) instead of setBackground (new color (0,0,0,0)); did not solve the problem.
  • "try adding validate () after package ()" did not solve the problem.
  • "draw a background image on JViewport" will not work, because the background must go beyond the scope of JScrollView, and also spreads behind other components
  • "change the graphic composite in the liner of the user interface delegate ()" If this solves the problem, I would like to know how to do it.
+4
source share
1 answer

Background Panel has code that tries to make all components opaque so that the background is displayed.

Edit:

If you want to play with a transparent background, you can check Backgrounds With Transparency for an explanation of the problem and several solutions.

In this case, BackgroundPane is an easier solution.

+5
source

All Articles