Need Java Swing equivalent of "scrollIntoView" from Browser DOM

Posted by bgould on Stack Overflow See other posts from Stack Overflow or by bgould
Published on 2010-06-13T18:04:43Z Indexed on 2010/06/13 18:12 UTC
Read the original article Hit count: 203

Filed under:
|
|

I have a JPanel with several levels of child components, also with a JScrollPane. I'm placing a focus listener on some of the child components to add some behavior to those components, but I would also like to have that component scroll into the JPanel's viewport when focus is gained.

My question is, does anyone have a general purpose function to do this, similar to the browser DOM function "scrollIntoView"? I've tried muddling through this with various inputs to JComponent.scrollRectToVisible but I guess I haven't figured out the magic word.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing