Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JScrollPane problem  RSS feed

 
Satheesh Thekku Veethil
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have a funny situation.
I have a panel onto which I am putting a JScrollPanel. The JScrollPanel occupies about 70% of the total parent panel and is positioned in the middle of the parent panel.
into the scroll panel i add some light weight components. so basically i have a scrollable control ui.
now when the light weight components are created i find an outline of them in a region outside the scroll panel. in fact the hidden part of the scroll panel shows outline of the components which it contains.
can u tell me whats the reason for this behaviour.
awaiting a quick reply
sat
 
Sudharsan Govindarajan
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posting your code can be helpful for us to see whatz going wrong.
Sudharsan
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how are you adding the components to the JScrollPane?
What you should do: Add all the components to a JPanel and add this JPanel to the JScrollPane. Be sure not to mix up swing and awt - this is often a reason for "funny behaviour".
Set the preferred size of the viewport:
scrollPane.getViewport().setPreferredSize(Dimension);
What LayoutManagement are you using in the parent component of the scrollpane? I would suggest to add the scrollpane either to a BorderLayout with the CENTER constraint, or to use GridBagLayout and to specify weightx and weighty both as 1.
chantal
 
Satheesh Thekku Veethil
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response.
I was adding it wrongly. Its working now and with "no funny behavior"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!