Example usage for javax.swing JComponent setDoubleBuffered

List of usage examples for javax.swing JComponent setDoubleBuffered

Introduction

In this page you can find the example usage for javax.swing JComponent setDoubleBuffered.

Prototype

public void setDoubleBuffered(boolean aFlag) 

Source Link

Document

Sets whether this component should use a buffer to paint.

Usage

From source file:Main.java

public static void resetBuffer(ArrayList<JComponent> dbcomponents) {
    for (JComponent jcomponent : dbcomponents) {
        jcomponent.setDoubleBuffered(true);
    }/*from  w  w  w  .  ja  va 2  s.  c o m*/
}

From source file:Main.java

public static void disableBuffer(Component comp, ArrayList<JComponent> dbcomponents) {
    if ((comp instanceof JComponent) && comp.isDoubleBuffered()) {
        JComponent jcomponent = (JComponent) comp;

        dbcomponents.add(jcomponent);/* w  w w  .  j av a  2s.  c om*/
        jcomponent.setDoubleBuffered(false);
    }

    if (comp instanceof Container) {
        Container container = (Container) comp;
        int count = container.getComponentCount();

        if (count > 0) {
            for (int i = 0; i < count; i++) {
                Component component = container.getComponent(i);

                disableBuffer(component, dbcomponents);
            }
        }
    }
}

From source file:Main.java

/**
 * Sets double buffered state of component and all of its children.
 *
 * @param component//from  ww w  .j a  va  2 s .  com
 *            component to modify
 * @param doubleBuffered
 *            whether use double buffering or not
 * @param childsOnly
 *            whether exclude component from changes or not
 */
public static void setDoubleBufferedRecursively(final Component component, final boolean doubleBuffered,
        final boolean childsOnly) {
    if (component instanceof JComponent) {
        final JComponent jComponent = (JComponent) component;
        if (!childsOnly) {
            jComponent.setDoubleBuffered(doubleBuffered);
        }
    }
    if (component instanceof Container) {
        for (final Component child : ((Container) component).getComponents()) {
            setDoubleBufferedRecursively(child, doubleBuffered, false);
        }
    }
}

From source file:com.projity.pm.graphic.network.NetworkRenderer.java

public void paintNode(Graphics2D g, GraphicNode node) {
    Rectangle bounds = getBounds(node);
    if (isEditing(node)) {
        editor.paintEditor(node);/*w ww  . jav a 2s .  c o m*/
    } else {
        JComponent c = renderer.getRendererComponent(node, ((NetworkParams) graphInfo).getZoom());
        if (container == null) {
            //c=new JLabel("test");
            c.setDoubleBuffered(false);
            c.setOpaque(false);
            c.setForeground(Color.BLACK);
            c.setSize(bounds.width, bounds.height);
            g.translate(bounds.x, bounds.y);
            c.doLayout();
            c.print(g);
            g.translate(-bounds.x, -bounds.y);
        } else
            rendererPane.paintComponent(g, c, container, bounds.x, bounds.y, bounds.width, bounds.height, true);
    }
}

From source file:org.jas.dnd.Jdk6u10TransparencyManager.java

private void doTheDoubleBuffer(Component c) {
    if (c instanceof JComponent) {
        JComponent comp = (JComponent) c;
        comp.setDoubleBuffered(false);
    }//from ww w  . j  a v a  2s  .  c  o m
    if (c instanceof Container) {
        Container container = (Container) c;
        for (Component c2 : container.getComponents()) {
            doTheDoubleBuffer(c2);
        }
    }

}

From source file:org.pentaho.reporting.engine.classic.core.util.ComponentDrawable.java

/**
 * Prepares the component for drawing. This recursively disables the double-buffering as this would interfere with the
 * drawing./*from   w  ww  . j a v a2 s.c o m*/
 *
 * @param c
 *          the component that should be prepared.
 */
private void prepareComponent(final Component c) {
    if (c instanceof JComponent) {
        final JComponent jc = (JComponent) c;
        jc.setDoubleBuffered(false);
        final Component[] childs = jc.getComponents();
        for (int i = 0; i < childs.length; i++) {
            final Component child = childs[i];
            prepareComponent(child);
        }
    }
}