Dmitry, First of all, thanks a lot for your help and advice. It has been very helpful to me, and I am sure to many other people on this mailing list. Secondly, I did try to remove the scroll pane from the picture and just add the panel directly to my applet instead. This is my goal anyway -- remove scrolling from the applet no matter what the size of the component/panel is. I call the JavaScript function to reset the overall size of the applet. This part works. What does not work, as I explained, is the part where I calculate the size/height of the panel. To explain the issue, I have a dropdown that loads a specific panel depending on the value selected in the dropdown. A typical panel has a variety of controls in it: combo boxes, JPanel components, lists, text areas, buttons, tables, lables, etc.
I don't overwrite the getPreferredSize() method in my panel(s). So, I expect the layout manager to compute this. I use GridBagLayout almost everywhere in the panels. I realize that the layout manager probably does not do a good job here for some reason. Howeber, since the JScrollPane internally calculates the size of the panel correctly and provides the appropriate scrolling, I assume I should be able to get the correct height of the main panel as well. Result I am getting now: Instead of, say, 1800-2000 height, I am getting 600 or so. So, it underestimates the height of the panel(s). Thanks! -----Original Message----- From: Dmitry Beransky [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 17, 2002 1:19 PM To: [EMAIL PROTECTED] Subject: Re: Preferred size or just size at run-time. 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 _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing