Java JScrollPane Scroll scrollRectLater(final JComponent comp, final Rectangle r)

Here you can find the source of scrollRectLater(final JComponent comp, final Rectangle r)

Description

scroll Rect Later

License

Open Source License

Declaration

public static void scrollRectLater(final JComponent comp, final Rectangle r) 

Method Source Code


//package com.java2s;
/*/*from   w w  w.j  a v a 2 s  .co m*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import javax.swing.*;

import java.awt.*;

public class Main {
    public static void scrollRectLater(final JComponent comp, final Rectangle r) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                comp.scrollRectToVisible(r);
            }
        });
    }

    /**   please read the following comments on scrollRectToVisible
     *    (from JRE source code:)
     *
    // NOTE: How JViewport currently works with the
    // backing store is not foolproof. The sequence of
    // events when setViewPosition
    // (scrollRectToVisible) is called is to reset the
    // views bounds, which causes a repaint on the
    // visible region and sets an ivar indicating
    // scrolling (scrollUnderway). When
    // JViewport.paint is invoked if scrollUnderway is
    // true, the backing store is blitted.  This fails
    // if between the time setViewPosition is invoked
    // and paint is received another repaint is queued
    // indicating part of the view is invalid. There
    // is no way for JViewport to notice another
    // repaint has occured and it ends up blitting
    // what is now a dirty region and the repaint is
    // never delivered.
    // It just so happens JTable encounters this
    // behavior by way of scrollRectToVisible, for
    // this reason scrollUnderway is set to false
    // here, which effectively disables the backing
    // store.
        
    * any idea how to solve this ?? 
    */
    public static void scrollRectToVisible(JComponent comp, Rectangle r) {
        comp.scrollRectToVisible(r);
    }
}

Related

  1. scrollComponentTo(JComponent c, Rectangle r)
  2. scrollComponentToEnd(JComponent c)
  3. scrolleable(final JComponent comp)
  4. scrollH(JComponent content)
  5. scrollRectToVisible(Component component, Rectangle aRect)
  6. scrollToComponent(Component cmp)
  7. scrollToVisible(int row, int col)
  8. scrollV(String title, JComponent content)