• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

Horizontally Scrollable JTextPane's

I'm setting up a JTextPane and JScrollPane to work together, and vertical scrolling works fine when newline-feeds exceed the viewport size.

I really want the JTextPane's size (rather, width) to be fixed so that areas of the text-pane falling outside of the view port are written to via the insertString() method. Instead, the JTextPane's width alters to fit the viewport when the frame is displayed; eliminating horizontal scrolling.

Any help on this is appreciated,

Sterry.
0
sterrius
Asked:
sterrius
  • 2
1 Solution
 
zzynxSoftware engineerCommented:
>> I really want the JTextPane's size (rather, width) to be fixed
try applying

 setPreferredSize()
 setMinimumSize()
 setMaximumSize()

with the same Dimension parameter
0
 
sterriusAuthor Commented:
The JTextPane now stays at a consistent size (the dimenstions are printed to the console after the frame is displayed), but the scrollbars of the ScrollPane do not reflect the size of the client JTextPane...

Does the ScrollPane need to be redrawn for the scrollbars to render properly?
0
 
zzynxSoftware engineerCommented:
>> The JTextPane now stays at a consistent size
Good. That was what you wanted, isn't it?
>> Does the ScrollPane need to be redrawn for the scrollbars to render properly?
Don't know. You can try it:

   yourScrollPane.revalidate();
   yourScrollPane.repaint();
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now