Hi,
When I use a highlighter in a JTextPane, the font color is not setting as
say in AttributeSet.
I use java 1.4.2_08 on Mandrake 10.0.
How is it possible to use both higlighter and font color ?
I have program which reproduce the thing :
package ahan;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class HiglightAndForeground
{
public static void main(String[] args) throws Exception
{
JFrame windo;
JTextPane textpane;
SimpleAttributeSet attributes;
DefaultHighlighter.DefaultHighlightPainter light;
windo = new JFrame();
windo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textpane = new JTextPane();
windo.getContentPane().add(textpane);
attributes = new SimpleAttributeSet();
StyleConstants.setForeground(attributes, Color.MAGENTA);
textpane.setCharacterAttributes(attributes, false);
textpane.setText("A l'heure vague où les fantômes en grand nombre");
light = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);
textpane.getHighlighter().addHighlight(4, 15, light);
windo.pack();
windo.show();
}
}
The color of text is magenta, but in the highlighter area it is black.
The problem exists only with java 1.4.2_08, not with 1.4.2 or 5.0... but I
use java 1.4.2_08 :-)
Great things.

Signature
Hervé AGNOUX
http://www.diaam-informatique.com
Christian Kaufhold - 26 Jul 2005 17:56 GMT
> When I use a highlighter in a JTextPane, the font color is not setting as
> say in AttributeSet.
>
> I use java 1.4.2_08 on Mandrake 10.0.
>
> How is it possible to use both higlighter and font color ?
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5003294
> I have program which reproduce the thing :
>
[quoted text clipped - 15 lines]
> windo = new JFrame();
> windo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textpane = new JTextPane()
{
public void updateUI()
{
super.updateUI();
setSelectedTextColor(null);
}
};
The best I can think of, short of rewriting GlyphView.paint (if possible
at all).
Christian