use of com.servoy.j2db.smart.dataui.ScriptButton in project servoy-client by Servoy.
the class GlobalAutoScrollerFocusListener method propertyChange.
public void propertyChange(PropertyChangeEvent e) {
if (// $NON-NLS-1$
"focusOwner".equals(e.getPropertyName())) {
Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null) {
// System.out.println("focus moved to ->" + owner.getClass().getCanonicalName() + "/" + owner + "<-");
// if (owner instanceof Component) System.out.println("\towner name is: " + (owner).getName());
// Container focusRoot = KeyboardFocusManager.getCurrentKeyboardFocusManager().getCurrentFocusCycleRoot();
// System.out.println("focus cycle root is now ->" + focusRoot.getClass().getCanonicalName() + "/" + focusRoot + "<-");
owner = getEventualParentScrollPane(owner);
/* Auto scroll only when our specific fields receive focus. */
if (owner instanceof IDisplayData || owner instanceof ScriptButton) {
/* Find a scrollable parent, if any. */
JComponent scrollableParent = findScrollableParent(owner);
while (scrollableParent != null) {
/* Compute the coordinates of the owner relative to the scrollable parent. */
Rectangle r = owner.getBounds();
Component c = owner.getParent();
while (c != scrollableParent && c != null) {
Rectangle s = c.getBounds();
r.setLocation(r.x + s.x, r.y + s.y);
c = c.getParent();
}
scrollableParent.scrollRectToVisible(r);
// If we are inside a tab panel, then we go up one level and scroll everything again,
// because the tab panel itself can be out of the screen now.
scrollableParent = findTabPanelParent(scrollableParent);
if (scrollableParent != null)
scrollableParent = findScrollableParent(scrollableParent.getParent());
}
}
}
}
}
Aggregations