Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Center a JPanel in JScrollPane and add a JToolBar

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..........
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic