• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Center a JPanel in JScrollPane and add a JToolBar

 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I add some elements to to my scrollPane unsing a gridlayout. There where in the middle of my ScrollPane. Now I must use a panel with these elements, but the panel is always on top.
1. How can I center a JPanel in a JScrollPane?
2. I want to add a ToolBar to the top and center the panel in my program. How can I do this?
Please help...Thanks a lot!
Here is the code:

[ June 28, 2002: Message edited by: Kay Tracid ]
[ July 01, 2002: Message edited by: Kay Tracid ]
 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help, it is important for me. I think it is just a layout problem. The toolBar can i add to north in a borderlayout. But how can I center the JPanel in the scrollPane?
Please..........
 
keerthi matta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Kay,
Dont worry,
U just need to make 1 change in your code.
1. In PicPanel class , u forgot to set the Layout of the JPanel,
just set the layout to BorderLayout.
and in Main Panel, no need to add the Panels to a JScollPane , u can add directly add the Panels to the SplitPane , adding ScollPane to Panels i think does not effect
hope this would solve ur problem
if i have understood it in right manner
ok njoy coding
keerthi
 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, it works now I thought borderlayout is the default layout. I dont know why I must set it...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic