Example usage for javax.swing RepaintManager isDoubleBufferingEnabled

List of usage examples for javax.swing RepaintManager isDoubleBufferingEnabled

Introduction

In this page you can find the example usage for javax.swing RepaintManager isDoubleBufferingEnabled.

Prototype

public boolean isDoubleBufferingEnabled() 

Source Link

Document

Returns true if this RepaintManager is double buffered.

Usage

From source file:MyJava3D.java

/**
 * It's possible to turn off double-buffering for just the repaint calls
 * invoked directly on the non double buffered component. This can be done
 * by overriding paintImmediately() (which is called as a result of repaint)
 * and getting the current RepaintManager and turning off double buffering
 * in the RepaintManager before calling super.paintImmediately(g).
 *///from w ww .  j  a va  2s.  c o  m
public void paintImmediately(int x, int y, int w, int h) {
    RepaintManager repaintManager = null;
    boolean save = true;
    if (!isDoubleBuffered()) {
        repaintManager = RepaintManager.currentManager(this);
        save = repaintManager.isDoubleBufferingEnabled();
        repaintManager.setDoubleBufferingEnabled(false);
    }
    super.paintImmediately(x, y, w, h);

    if (repaintManager != null) {
        repaintManager.setDoubleBufferingEnabled(save);
    }
}