JScrollPane + JTextPane trouble.

34 views
Skip to first unread message

Christian Vest Hansen

unread,
Jan 18, 2009, 7:08:47 PM1/18/09
to clojure group
Hi!

Now, I know this is more related to Swing than Clojure, but they won't
be able to read my code in a general Java forum.

I have a JTextPane [1] inside a JScrollPane [2] and I would like to
have horizontal scrollbars rather than word-wrapping. I try to disable
word-wrapping by overriding the JTextPane.setSize method such that the
dimensions from the JTextPane.getPreferredSize is used instead of the
dimension parameter parsed to .setSize. The consequence of this
disabled word-wrapping but there is an unwanted side-effect: there is
no horizontal scrollbar when the content is wide and even if I force
the horizontal scrollbar through policy on the JScrollPane, they will
have no effect. Any attempt to move the document using the forced
horisontal scrollbars will see the document jumping right back to
where it came from.

Finally, it may be worth to mention that this JScrollPane is used in a
JSplitPane [3], in the event that makes any difference.

I hope someone can tell me what I'm doing wrong here.

[1]: http://github.com/karmazilla/textjure/blob/b184f842686861a3b4a947a24ea92a610edd8b46/textjure.clj#L271
[2]: http://github.com/karmazilla/textjure/blob/b184f842686861a3b4a947a24ea92a610edd8b46/textjure.clj#L318
[3]: http://github.com/karmazilla/textjure/blob/b184f842686861a3b4a947a24ea92a610edd8b46/textjure.clj#L627

--
Venlig hilsen / Kind regards,
Christian Vest Hansen.

MikeM

unread,
Jan 19, 2009, 9:26:46 AM1/19/09
to Clojure

Christian Vest Hansen

unread,
Jan 19, 2009, 2:11:48 PM1/19/09
to clo...@googlegroups.com
Excellent!

The getScrollableTracksViewportWidth() trick did it :)

On Mon, Jan 19, 2009 at 3:26 PM, MikeM <michael.m...@invista.com> wrote:
>
> This might be helpful:
>
> http://os-lists.sun.com/thread.jspa?messageID=457986
> >
>



Reply all
Reply to author
Forward
0 new messages