Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2005

Tip: Looking for answers? Try searching our database.

Highlighter remove font color

Thread view: 
Hervé AGNOUX - 21 Jul 2005 08:01 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.