If you haven't overridden getPreferredSize() of JPanel and don't use non-standard Look and Feel, then the preferred size is computed by the panel's layout manager. Are you using a layout manager? What are the incorrect numbers that you're seeing and what do you expect to see? In my experience scroll panes have always been the source of sizing problems (but, frankly, I don't have enough experience working with them, so I don't quite understand what makes them tick). Do you get the expected value if you take the scroll pane temporarily out of the picture? Some component (eg. JLabels because they need font metrics) rely on a valid graphics context to be present. This means that you can will not get a valid result until after addNotified() had been called. This is a complicated issue, and the more info you can provide about your setup the better :)
Cheers Dmitry At 06:54 AM 1/17/2002, Reinstein, Lenny wrote: >I am trying to determine the size of my panel at run-time. I.e., I have a >panel that contains many other panels with multiple controls/components that >I place into a scroll pane and then into the applet. However, when I call >the getPreferredSize method on the panel, it does not return the correct >size. Is there a way to get this "right" size from it? I call "validate" >before calling getPreferredSize. > >Many thanks. _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing
