javax.swing.RepaintManager Java Examples

The following examples show how to use javax.swing.RepaintManager. 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 File: CharacterSheet.java    From gcs with 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 #2
Source File: TagsAndEditorsTest.java    From netbeans with 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 #3
Source File: bug6608456.java    From jdk8u_jdk with 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
Source File: bug6608456.java    From jdk8u-jdk with 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 #5
Source File: SwingUtilities3.java    From dragonwell8_jdk with 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 #6
Source File: bug6608456.java    From dragonwell8_jdk with 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 File: SwingUtilities3.java    From jdk8u-jdk with 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 #8
Source File: JXPanel.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * Set the alpha transparency level for this component. This automatically
 * causes a repaint of the component.
 *
 * @param alpha must be a value between 0 and 1 inclusive.
 */
public void setAlpha(float alpha) {
    if (alpha < 0 || alpha > 1) {
        throw new IllegalArgumentException("Alpha must be between 0 and 1 inclusive");
    }

    if (this.alpha != alpha) {
        float oldAlpha = this.alpha;
        this.alpha = alpha;
        if (alpha > 0f && alpha < 1f) {
            if (oldAlpha == 1) {
                //it used to be 1, but now is not. Save the oldOpaque
                oldOpaque = isOpaque();
                setOpaque(false);
            }

            //TODO this was quite the controversial choice, in automatically
            //replacing the repaint manager. In retrospect, I'd probably
            //opt for making this a manual choice. There really isn't a clear
            //win, no matter the approach.
            RepaintManager manager = RepaintManager.currentManager(this);
            if (!manager.getClass().isAnnotationPresent(TranslucentRepaintManager.class)) {
                RepaintManager.setCurrentManager(new RepaintManagerX());
            }
        } else if (alpha == 1) {
            //restore the oldOpaque if it was true (since opaque is false now)
            if (oldOpaque) {
                setOpaque(true);
            }
        }
        firePropertyChange("alpha", oldAlpha, alpha);
        repaint();
    }
}
 
Example #9
Source File: bug6608456.java    From jdk8u-dev-jdk with 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 #10
Source File: SwingAccessor.java    From hottub with 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 File: SwingAccessor.java    From dragonwell8_jdk with 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 #12
Source File: SwingAccessor.java    From jdk8u60 with 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 #13
Source File: SwingUtilities3.java    From Bytecoder with 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 #14
Source File: SwingUtilities3.java    From jdk8u_jdk with 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 #15
Source File: bug6608456.java    From openjdk-8 with 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 #16
Source File: bug6608456.java    From jdk8u60 with 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
Source File: bug6608456.java    From openjdk-8 with 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 #18
Source File: bug6608456.java    From openjdk-8-source with 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 #19
Source File: SwingAccessor.java    From openjdk-jdk8u with 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 #20
Source File: bug6608456.java    From openjdk-jdk8u-backup with 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 #21
Source File: bug6608456.java    From jdk8u-dev-jdk with 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 #22
Source File: SwingUtilities3.java    From openjdk-jdk8u with 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 #23
Source File: SwingAccessor.java    From jdk8u_jdk with 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 #24
Source File: bug6608456.java    From openjdk-jdk8u with 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 #25
Source File: AnimationLayer.java    From netbeans with 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 #26
Source File: SwingUtilities3.java    From jdk8u-dev-jdk with 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 #27
Source File: QueryBuilder.java    From netbeans with 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 #28
Source File: DebuggingViewComponent.java    From netbeans with 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 #29
Source File: ComponentDrawable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #30
Source File: SwingAccessor.java    From openjdk-jdk8u-backup with 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;
}