Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JTextPane selection color problem

843806Oct 24 2008 — edited Oct 24 2008
I 've createa a simple editor by using jtextpane, but i have a problem about the selection color :

when i drag the mouse to select some text in the textpane, the selection color is blue (see figure below)

http://i35.photobucket.com/albums/d186/bobbi2004/1.gif

and then i change the style, bold for example, but the selection color becomes transparent (although there is still a selection there.)
http://i35.photobucket.com/albums/d186/bobbi2004/2-1.gif

i have seen some example about jtextpane but there was no problem, but i can't figure it out why.
thanks for helping me.

ps : this is the NetBeans source files for this editor.
http://www.mediafire.com/?iukjmvj5mwn


thanks again, and sorry for my bad english

Edited by: bobbi2004 on Oct 24, 2008 12:21 AM

Comments

darrylburke
It's my experience here that members aren't too interested in downloading code posted on some other site (which may be blocked from many offices), and even less interested in looking at ugly, over-complicated IDE generated code. To get better help sooner, post a SSCCE that clearly demonstrates your problem. Not the entire program, just a short-as-possible compilable code that can be indempendently executed.

Use code tags to post codes -- [code]CODE[/code] will display as
CODE
Or click the CODE button and paste your code between the {code} tags that appear.

db
843806
sorry , but i don't really know where the problem is, so i just post it entirely, about the pictures, i can't post picture in sun forum, so i put them online.
camickr
but the selection color becomes transparent (although there is still a selection there.)
The selection is only painted when the text pane has focus.

Make your buttons non-focusable and the focus will remain on the text pane even when you click the button.

button.setFocusable( false );
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 21 2008
Added on Oct 24 2008
3 comments
357 views