This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,878 Users
  • 2,269,775 Discussions
  • 7,916,823 Comments

Discussions

JTextPane selection color problem

843806
843806 Member Posts: 49,998
edited Oct 24, 2008 11:34AM in Swing
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
    darrylburke Member Posts: 18,007
    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
    843806 Member Posts: 49,998
    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
    camickr Member Posts: 24,931 Silver Badge
    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 );
This discussion has been closed.