Example usage for javax.swing SwingUtilities getLocalBounds

List of usage examples for javax.swing SwingUtilities getLocalBounds

Introduction

In this page you can find the example usage for javax.swing SwingUtilities getLocalBounds.

Prototype

public static Rectangle getLocalBounds(Component aComponent) 

Source Link

Document

Return the rectangle (0,0,bounds.width,bounds.height) for the component aComponent

Usage

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * Ensures that the passed component is visible. 
 * @param component The component.//from  ww w  .  j  a v  a 2  s .  c  o m
 * @param bounds Optional bounds inside the component. If not <code>null</code>, the bounds are scrolled to visible.
 * @throws RobotException If the component's screen location cannot be calculated.
 */
private void ensureComponentVisible(final Component component, final Rectangle bounds) throws RobotException {
    m_queuer.invokeAndWait("ensureVisible", new IRunnable() { //$NON-NLS-1$
        public Object run() {
            Rectangle rectangle = bounds != null ? new Rectangle(bounds)
                    : SwingUtilities.getLocalBounds(component);
            if (log.isDebugEnabled()) {
                log.debug("Scrolling rectangle to visible: " + rectangle); //$NON-NLS-1$
            }
            Scroller scroller = new Scroller(component);
            scroller.scrollRectToVisible(rectangle);
            return null;
        }
    });
}