This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Originally posted by Maneesh Godbole: You need to set the layout of the panel to border layout.
No you don't. The panel can have any layout it wants, and any controls.
However, you have shown me the light. The scroll pane by default only shows its scroll bars if needed. However, the panel inside has no controls, and therefore a preferred size of 0x0 (or something similarly small). Therefore, the panel will fit on your applet's content pane, and no scroll bars are needed.
There are three ways to get the scroll pane to be shown: 1) initialize the scroll pane with scrolling policies:
You can also set them using setHorizontalScrollBarPolicy and setVerticalScrollBarPolicy later.
2) add something to your panel that won't fit in your applet:
3) set the preferred size of the panel to a size bigger than the applet:
When the scroll bar policies are set to "AS_NEEDED", which happens by default, the scroll pane will use the panel's preferred size to determine whether or not to show the scroll bars. The panel's preferred size will be the size set using setPreferredSize (option 3), or if none was set the preferred size determined by its layout manager. The layout manager usually uses the components inside the panel for determining that preferred size.
Joined: Sep 18, 2007
Thank you...The pane is showing now..But the problem is when i scroll down the drawing is going up..And if scroll up again the its not showing(drawing)..The same problem happens if i re-size my window.. [ October 21, 2007: Message edited by: shalini gnana ]