Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

focus moved, JScrollPane scroll to new component question.  RSS feed

 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!