focus moved, JScrollPane scroll to new component question.
posted 14 years ago
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?
posted 13 years ago
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.