Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Center a JPanel in JScrollPane and add a JToolBar

 
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..........
 
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...
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic