• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

repaint in ScrollPane does not work correctly

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a scollpane and a Panel in it.
Without the scollpane, I can resize my Panel as I want, it repaints always correctly.

I don't use any Layout manager, I ask how much size does my frame gives me to draw and then calculate all relative corrdinates from this numbers.

Why does it display wrong when scrolling in the scrollpane?
Is it possible to catch all the events, that my scollpane sends to my Panel?

Maybe that would be a way to see what really happens/what goes wrong...
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each time the JScrollPane must validate itself it looks for the size of its viewports child, your JPanel, which it uses to set its scrollbars. So your custom component must let the JScollPane know what size it is or wants to be shown with. One way to do this is to override the JComponent method getPreferredSize in your component and return the desired Dimension. The JScrollPane will ask for this during each validate episode.

Calling the JComponent method revalidate on an instance of MyPanel in your event code signals the JScrollPane to validate itself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic