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 / May 2005

Tip: Looking for answers? Try searching our database.

Color for underlining in JTextPane

Thread view: 
Rene Ruppert - 12 May 2005 12:39 GMT
Hi,

I use this code to underline text in a JTextPane:

SimpleAttributeSet attributes = new SimpleAttributeSet();
 StyleConstants.setUnderline(attributes, true);
 StyledDocument document = getStyledDocument();
 document.setCharacterAttributes(0, getText().length(), attributes,
  true);

How can I change the color of the line? By default the color is the same as
the text color...

Thanks.

René
Christian Kaufhold - 13 May 2005 14:17 GMT
> SimpleAttributeSet attributes = new SimpleAttributeSet();
>  StyleConstants.setUnderline(attributes, true);
[quoted text clipped - 4 lines]
> How can I change the color of the line? By default the color is the same as
> the text color...

Not so easy. The painting is done in GlyphView.paintTextUsingColor (which is
package-private) and always in the same color as the text.
It will need a lot of rewriting to replace it.

At least underlining is not done by TextLayout, where there is no control
over the color (or style) 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.