|
I believe I may have solved this
one:
It looks like the JTextPane assumes text
should be on top of everything else and makes a copy of the graphics
object
and paints it last.
I dug into the code and found where it
passes that new graphics object to the StyledDocument to paint itself to
and
started there instead:
Rectangle alloc =
getVisibleEditorRect(); t.getUI().getRootView(ta).paint(g2,
alloc);
This bypasses the Swing RepaintManager and
passes the graphics directly to the StyledDocument to paint.
If anyone sees something else that perhaps
would work better, please let me know.
Bill Ensley
Bear Printing
Hello All!
Interesting bug? here, I am using a JTextPane for
styled text and am calling
it's
paint() method and passing a Graphics object to it to paint itself
onto.
This
works well with other Graphics objects, ie Screen, BufferedImage, Print,
etc.
But
when I pass it a PdfGraphics2D object it always wants to be painted on the
top.
ie:
JTextPane t = new
JTextPane(); t.setText("hello world - hello world
"); t.setSize(300,300); t.setLocation(75,75);
t.setVisible(true); t.setOpaque(false); t.paint(g2);
g2.setColor(Color.GREEN); g2.fillRect(50,0,25,25);
This
code will paint the JTextPane on top of the rectangle.
If
anybody has any bright ideas, I would be greatful.
Bill
Ensley
Bear
Printing
|