• Post Reply Bookmark Topic Watch Topic
  • New Topic

focus moved, JScrollPane scroll to new component question.

 
bing deng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have a JScrollPane with several components contained in it. When the focus for a component is moved to a component that is not visible in the Viewport of the JScrollPane, the Viewport doesn't automatically display the component receiving focus. How can I get the JScrollPane to scroll to the new Component receiving the focus?
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add FocusListener to the components, in focusGained() method, use scrollRectToVisible(rect) on the scrollpane - where rect being the area in which the component lies on the scrollpane.
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!