Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

problem with JScrollPane  RSS feed

 
Ranch Hand
Posts: 4702
9
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have two apps. one called ImageViewer has scrollbars. the other i am trying to add them. with ImageViewer it was simple

similar code for the other program doesn't display the scrollbars

DrawingArea extends JPanel
 
Sheriff
Posts: 21421
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the preferred size of the DrawingArea?
 
Randall Twede
Ranch Hand
Posts: 4702
9
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from what i can gather, that is the problem. it apparently wasn't a problem for the JLabel though. i will list more code.
ImageViewer

ImageViewer fixed for problem when frame is maximized

Paint
 
Randall Twede
Ranch Hand
Posts: 4702
9
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paint has some unnecessary imports. i have been busy refactoring
 
Bartender
Posts: 3320
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to control the scroll bars visibility then use one of the JScrollPane constructors that always you to set the scroll bar policy for each axis to one of the following (default is XXX_AS_NEEDED):

For vertical axis:
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS

For horizintal axis:
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS

 
Randall Twede
Ranch Hand
Posts: 4702
9
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as you say, AS_NEEDED is what i want. i just have to figure out this preferred size issue it looks like.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would override getPreferredSize() to compute and return an appropriate Dimension. If the computation is expensive, and doesn't change, I would do it at construction and store the value in a field.

Depending on the layout manager used and the factors that determine the preferred size, it may be prudent to also override getMinimum/MaximumSize().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!