?
Solved

Horizontally Scrollable JTextPane's

Posted on 2005-03-24
5
Medium Priority
?
570 Views
Last Modified: 2008-03-03
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
Comment
Question by:sterrius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 13623450
>> I really want the JTextPane's size (rather, width) to be fixed
try applying

 setPreferredSize()
 setMinimumSize()
 setMaximumSize()

with the same Dimension parameter
0
 

Author Comment

by:sterrius
ID: 13625109
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
 
LVL 37

Expert Comment

by:zzynx
ID: 13628321
>> 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question