Disabling text selection in JTextPane

Dear all,

I want to create a JLabel, which should create multiple lines if the current view is too short to show the text at one line. I searched the forum for this, and I did find a solution ( http://forum.java.sun.com/thread.jspa?forumID=57&threadID=748511 ) , but unfortunately I can't get that thing working properly when I use a SpringLayout (I bind the JLabel to both the EAST and the WEST side of the JPanel). First of all, the getPrefferedSize() of the JLabel returns a width that doesn't match with the size of the JPanel. Secondly, when I resize the JPanel, the text inside the JLabel is being wrapped perfectly, but the JLabel itself retains the same size. For this, the JLabel will be too high or too small, depends on whether you make your JPanel larger or smaller.

If anyone has a solution for my problem mentioned above, please feel free to answer :)

So I decided just to use a JTextPane for my solution. But I would like to make the text selection disabled. I haven't been able to find a method for that in the API, so maybe I missed it or there is a tricky way to do it... the way I don't know of course ;)

Disabling the JTextPane has no use, since the text will be gray instead of black (using the setForeground(Color.BLACK) doesn't work somehow).

Tx in advance to any reaction!

Peter

[1354 byte] By [Nemesish3da] at [2007-11-27 4:30:01]
# 1
okay guys sorry :$ I just didn't search hard enough in the API I guess.myTextPane.setDisabledTextColor(Color.BLACK);sorry for the inconvenience. Anyway, I would really like to have some reactions on my first question ;)
Nemesish3da at 2007-7-12 9:39:11 > top of Java-index,Desktop,Core GUI APIs...
# 2
You can add a caret listener which will reset selection start to be equal selection end.regards,Stas
StanislavLa at 2007-7-12 9:39:11 > top of Java-index,Desktop,Core GUI APIs...