Java Code Examples for javax.swing.RepaintManager

The following examples show how to use javax.swing.RepaintManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   Source File: TagsAndEditorsTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testPropertySheetRepaintsCellOnPropertyChange() throws Exception {
    if (!canSafelyRunFocusTests()) {
        return;
    }
    Node n = new TNode(new SingleTagEditor());
    setCurrentNode(n, ps);
    Rectangle test = ps.table.getCellRect(1, 1, true);
    RM rm = new RM(test, ps.table);
    RepaintManager.setCurrentManager(rm);
    sleep();
    sleep();
    Node.Property prop = n.getPropertySets()[0].getProperties()[0];
    prop.setValue("new value");
    Thread.currentThread().sleep(1000);
    sleep();
    rm.assertRectRepainted();
}
 
Example 2
Source Project: gcs   Source File: CharacterSheet.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
    if (pageIndex >= getComponentCount()) {
        mLastPage = -1;
        return NO_SUCH_PAGE;
    }

    // We do the following trick to avoid going through the work twice,
    // as we are called twice for each page, the first of which doesn't
    // seem to be used.
    if (mLastPage == pageIndex) {
        Component      comp  = getComponent(pageIndex);
        RepaintManager mgr   = RepaintManager.currentManager(comp);
        boolean        saved = mgr.isDoubleBufferingEnabled();
        mgr.setDoubleBufferingEnabled(false);
        mOkToPaint = true;
        comp.print(graphics);
        mOkToPaint = false;
        mgr.setDoubleBufferingEnabled(saved);
    } else {
        mLastPage = pageIndex;
    }
    return PAGE_EXISTS;
}
 
Example 3
Source Project: hottub   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 4
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
 
Example 5
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 6
Source Project: dragonwell8_jdk   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
 
Example 7
Source Project: jdk8u-dev-jdk   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
 
Example 8
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 9
Source Project: TencentKona-8   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 10
Source Project: jdk8u60   Source File: SwingAccessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
 
Example 11
Source Project: openjdk-8   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
 
Example 12
Source Project: jdk8u60   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 13
Source Project: openjdk-8   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 14
Source Project: jdk8u_jdk   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 15
Source Project: openjdk-jdk8u   Source File: SwingAccessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
 
Example 16
Source Project: jdk8u-dev-jdk   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 17
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 18
Source Project: jdk8u_jdk   Source File: SwingAccessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean registerDelegate(JComponent c,
        RepaintManager repaintManager) {
    boolean rv = false;
    try {
        Class<?> clazz = Class.forName("com.sun.java.swing.SwingUtilities3");
        Method method = clazz.getMethod("setDelegateRepaintManager",
            JComponent.class, RepaintManager.class);
        method.invoke(clazz, c, repaintManager);
        rv = true;
    } catch (Exception ignore) {
    }
    return rv;
}
 
Example 20
Source Project: netbeans   Source File: AnimationLayer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initial point of the next frame (invoked by the animation timer).
 *
 * @param e action event.
 */
@Override
public void actionPerformed(ActionEvent e) {
    updatePhase();
    RepaintManager manager = RepaintManager.currentManager(glassPane);
    manager.markCompletelyDirty(glassPane);
    manager.paintDirtyRegions();
}
 
Example 21
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 22
Source Project: netbeans   Source File: QueryBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private static void doShowBusyCursor(boolean busy) {
    JFrame mainWindow = (JFrame)WindowManager.getDefault().getMainWindow();
    if(busy){
        RepaintManager.currentManager(mainWindow).paintDirtyRegions();
        mainWindow.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        mainWindow.getGlassPane().setVisible(true);
        mainWindow.repaint();
    } else {
        mainWindow.getGlassPane().setVisible(false);
        mainWindow.getGlassPane().setCursor(null);
        mainWindow.repaint();
    }
}
 
Example 23
Source Project: netbeans   Source File: DebuggingViewComponent.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Restore stored scroll position.
 */
private void restoreScrollPosition(boolean delayScrollWithMarkingDirtyRegion) {
    if (visibleTreePosition != null) {
        JTree tree = getJTree();
        if (tree != null) {
            int row = tree.getRowForPath(visibleTreePosition.getPath());
            if (row != -1) {
                Rectangle bounds = tree.getRowBounds(row);
                if (bounds != null) {
                    int scrollY = bounds.y - visibleTreePosition.getOffset();
                    JViewport viewport = mainScrollPane.getViewport();
                    Rectangle rect = viewport.getViewRect();
                    rect.y = scrollY;
                    if (!rect.isEmpty()) {
                        JComponent view = (JComponent) viewport.getView();
                        if (delayScrollWithMarkingDirtyRegion) {
                            RepaintManager.currentManager(viewport).addDirtyRegion(
                                    view,
                                    rect.x, rect.x, rect.width, rect.height);
                        }
                        ignoreScrollAdjustment = true;
                        try {
                            view.scrollRectToVisible(
                                    rect);
                        } finally {
                            ignoreScrollAdjustment = false;
                        }
                    }
                }
            }
        }
    }
}
 
Example 24
/**
 * A helper method that performs some cleanup and disconnects the component from the AWT and the Swing-Framework to
 * avoid memory-leaks.
 */
protected final void cleanUp() {
  if ( component instanceof JComponent && isOwnPeerConnected() == false ) {
    final JComponent jc = (JComponent) component;
    RepaintManager.currentManager( jc ).removeInvalidComponent( jc );
    RepaintManager.currentManager( jc ).markCompletelyClean( jc );
  }
  contentPane.removeAll();
  RepaintManager.currentManager( contentPane ).removeInvalidComponent( contentPane );
  RepaintManager.currentManager( contentPane ).markCompletelyClean( contentPane );
  peerSupply.dispose();
}
 
Example 25
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}
 
Example 26
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
 
Example 27
Source Project: jdk8u_jdk   Source File: SwingUtilities3.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 28
Source Project: Bytecoder   Source File: SwingUtilities3.java    License: Apache License 2.0 5 votes vote down vote up
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 29
Source Project: openjdk-8-source   Source File: bug6608456.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    if (RepaintManager.currentManager(c) == this) {
        testFuture.defaultCalled();
    } else {
        testFuture.delegateCalled();
    }
    super.addDirtyRegion(c, x, y, w, h);
}
 
Example 30
Source Project: jdk8u-dev-jdk   Source File: SwingAccessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieve the accessor object for the RepaintManager class.
 */
public static RepaintManagerAccessor getRepaintManagerAccessor() {
    if (repaintManagerAccessor == null) {
        unsafe.ensureClassInitialized(RepaintManager.class);
    }
    return repaintManagerAccessor;
}