Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

relayouting after setViewportView for JScrollPane

 
Sergio Baca
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 JTextArea objects which I'm setting to same JScrollPane, the problem is that one object have bigger text than other and has Vertical Scrollbar, both JTextArea objects have word wrap enabled so they should not have Horizontal Scroll Bar, but when I move from JTextArea with no Vertical Scrollbar, to JTextArea with it, the resulting object is slightly bigger and a Horizontal Scrollbar appears.
Is there a way to call some kind of layout so that size will be evaluated each time ViewportView is set (or after it is set)?
 
Laba Jolly
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sergio Baca:
I have 2 JTextArea objects which I'm setting to same JScrollPane, the problem is that one object have bigger text than other and has Vertical Scrollbar, both JTextArea objects have word wrap enabled so they should not have Horizontal Scroll Bar, but when I move from JTextArea with no Vertical Scrollbar, to JTextArea with it, the resulting object is slightly bigger and a Horizontal Scrollbar appears.
Is there a way to call some kind of layout so that size will be evaluated each time ViewportView is set (or after it is set)?

Can you please clarify your problem? I have some experience with java text elements and may be I can help. Why don't you change text in JTextArea but change text elements in JScrollPane?
 
Sergio Baca
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Laba Jolly:

Can you please clarify your problem? I have some experience with java text elements and may be I can help. Why don't you change text in JTextArea but change text elements in JScrollPane?

I simplified my problem, here is the code:

When I enlarge window, it automatically relayout text, but when I shrink it back, instead of relayout a horizontal scrollbar is appearing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic