I hope I can get some help with this question concerning the following code.
The problem I am having is the setPreferredSize on the DrawingPanel. When the DrawingPanel object is created pictures (image) are loaded along with a description (text) of each one using Graphics2D commands in pic.ViewNewPicturesReport(g2). The scrollPanel does not scroll to the bottom of the report but only shows what one screen would look like. When I set the panel.setPreferredSize to some large dimension like (1500, 3500), then the scrollPanel will scroll to the end of the report. If I have a short amount of pictures the end of the scroll area could be way down, likewise if I have a large number of pictures and text then the scroll would stop before the end of the report. i have tried letting the DrawingPanel set the preferred size using getPreferredSize but didn't even have a scrolling area.
I couple of other items, I have tried using pack, validate, and revalidate after returning from the new DrawingPanel. All those methods doesn't seem to have any positive effect on the proper scrolling range.
How can I get the scrollPane to correctly determine what the end of the DrawingPanel's view and scroll correctly?
Everything I've seen on setPreferredSize seems to preset the Dimension in code. Can this be done using a method of Graphics2D? some other method? or maybe some formula?
Thanks for the post.
The location of the images are stored in a database, their may be none or many pictures. The size of the image can varying depending upon the resolution that the picture was taken in, we don't scale them.
In the DrawingPanel, I have tried setPreferredSize(getPreferredSize()) upon returning from the pic.ViewNewPicturesReport method. Which return (10,10 being returned and no scrollbars. Which is way to small, my main Frame is set to (853, 1450).
I have tired the setPreferredSize(getPreferredSize()) after adding the panel to the JScrollBar in the ctor of ConditionViewPrintFrame with the same value of (10,10) being returned and again scrollbars.
If the PicturesArea class doesn't expose an API to determine directly or indirectly the dimensions of the area it paints to, then there's no way you can achieve your goal. Or at least, not without a totally hackish and inefficient approach like painting to a BufferedImage sized larger than the maximum possible size and scanning the pixels to find the highest-value column and row with non-default color.
There are no new questions, but there may be new answers.
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad: