javax.swing.RepaintManager#currentManager ( )源码实例Demo

下面列出了javax.swing.RepaintManager#currentManager ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-dev-jdk   文件: bug6608456.java
@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);
}
 
源代码2 项目: dragonwell8_jdk   文件: bug6608456.java
@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);
}
 
源代码3 项目: ghidra   文件: HexOrDecimalInputTest.java
@Test
public void testCustomPaint() {

	HexOrDecimalInput input = new HexOrDecimalInput();
	RepaintManager repaintManager = RepaintManager.currentManager(input);
	repaintManager.setDoubleBufferingEnabled(false);

	SpyPrintStream spy = new SpyPrintStream();
	DebugGraphics.setLogStream(spy);

	DebugGraphics debugGraphics = new DebugGraphics(scratchGraphics());
	debugGraphics.setDebugOptions(DebugGraphics.LOG_OPTION);

	Graphics2D g2d = new Graphics2DAdapter(debugGraphics);
	input.paintComponent(g2d);
	assertThat(spy.toString(), CoreMatchers.containsString("Dec"));

	spy.reset();
	input.setHexMode();
	input.paintComponent(g2d);
	assertThat(spy.toString(), CoreMatchers.containsString("Hex"));

	spy.reset();
	input.setDecimalMode();
	input.paintComponent(g2d);
	assertThat(spy.toString(), CoreMatchers.containsString("Dec"));
}
 
源代码4 项目: jdk8u60   文件: bug6608456.java
@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);
}
 
源代码5 项目: openjdk-jdk8u   文件: bug6608456.java
@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);
}
 
源代码6 项目: jdk8u-jdk   文件: bug6608456.java
@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);
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: bug6608456.java
@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);
}
 
源代码8 项目: gcs   文件: UIUtilities.java
/** @param comp The component to revalidate. */
public static void revalidateImmediately(Component comp) {
    if (comp != null) {
        RepaintManager mgr = RepaintManager.currentManager(comp);
        mgr.validateInvalidComponents();
        mgr.paintDirtyRegions();
    }
}
 
源代码9 项目: hottub   文件: bug6608456.java
@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);
}
 
源代码10 项目: openjdk-8-source   文件: bug6608456.java
@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);
}
 
源代码11 项目: beautyeye   文件: JXPanel.java
/**
 * 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();
    }
}
 
源代码12 项目: jdk8u_jdk   文件: bug6608456.java
@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);
}
 
源代码13 项目: littleluck   文件: JXPanel.java
/**
 * 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();
    }
}
 
源代码14 项目: bigtable-sql   文件: PrintUtilities.java
public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
}
 
源代码15 项目: netbeans   文件: NbPresenterLeakTest.java
@RandomlyFails // NB-Core-Build #1189
public void testLeakingNbPresenterDescriptor () throws InterruptedException, InvocationTargetException {
    try {
        Class.forName("java.lang.AutoCloseable");
    } catch (ClassNotFoundException ex) {
        // this test is known to fail due to JDK bugs 7070542 & 7072167
        // which are unlikely to be fixed on JDK6. Thus, if AutoCloseable
        // is not present, skip the test
        return;
    }
    
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels(), null);
    wizardDescriptor.setModal (false);
    Dialog dialog = DialogDisplayer.getDefault ().createDialog (wizardDescriptor);
    WeakReference<WizardDescriptor> w = new WeakReference<WizardDescriptor> (wizardDescriptor);
    
    SwingUtilities.invokeAndWait (new EDTJob(dialog, true));
    assertShowing("button is visible", true, dialog);
    SwingUtilities.invokeAndWait (new EDTJob(dialog, false));
    assertShowing("button is no longer visible", false, dialog);
    boolean cancelled = wizardDescriptor.getValue() !=
        WizardDescriptor.FINISH_OPTION;
    Dialog d = new JDialog();
    
    // workaround for JDK bug 6575402
    JPanel p = new JPanel();
    d.setLayout(new BorderLayout());
    d.add(p, BorderLayout.CENTER);
    JButton btn = new JButton("Button");
    p.add(btn, BorderLayout.NORTH);
    
    SwingUtilities.invokeAndWait (new EDTJob(d, true));
    assertShowing("button is visible", true, btn);
    dialog.setBounds(Utilities.findCenterBounds(dialog.getSize()));
    SwingUtilities.invokeAndWait (new EDTJob(d, false));
    assertShowing("button is no longer visible", false, btn);

    assertNull ("BufferStrategy was disposed.", dialog.getBufferStrategy ());

    RepaintManager rm = RepaintManager.currentManager(dialog);
    rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
    rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
    
    dialog = null;
    wizardDescriptor = null;
    
    SwingUtilities.invokeAndWait (new Runnable() {

        @Override
        public void run() {
            Frame f = new Frame();
            f.setPreferredSize( new Dimension(100,100));
            f.setVisible( true );
            JDialog dlg = new JDialog(f);
            dlg.setVisible(true);
        }
    });

    assertGC ("Dialog disappears.", w);
}
 
源代码16 项目: netbeans   文件: DebugRepaintManager.java
public static void register(JComponent component) {
    if (RepaintManager.currentManager(component) != INSTANCE) {
        RepaintManager.setCurrentManager(INSTANCE);
    }
    INSTANCE.addLogComponent(component);
}
 
源代码17 项目: ApprovalTests.Java   文件: PrintUtils.java
public static void disableDoubleBuffering(Component c)
{
  RepaintManager currentManager = RepaintManager.currentManager(c);
  currentManager.setDoubleBufferingEnabled(false);
}
 
源代码18 项目: bigtable-sql   文件: PrintUtilities.java
public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
}
 
private static void doTest() {
    RepaintManager repaintManager = RepaintManager.currentManager(frame);
    textArea.append("DoubleBufferMaximumSize: " + repaintManager.getDoubleBufferMaximumSize() + "\n");
}
 
源代码20 项目: VanetSim   文件: DrawingArea.java
/**
 * Setting the <code>RepaintManager</code> like seen
 * <a href=http://java.sun.com/products/java-media/2D/samples/index.html>on the official examples for Java2D</a>
 * (link last time checked on 12.08.2008).<br>
 * This imitates the "On Screen" method used there and in some cases drastically improves performance (even when
 * DoubleBuffering of this <code>JComponent</code> is off the DoubleBuffering might still be on because the
 * DoubleBuffering is inherited from the main <code>JFrame</code>!).
 * 
 * @param x			the x coordinate for the bounding box to repaint
 * @param y			the y coordinate for the bounding box to repaint
 * @param width		the width
 * @param height	the height
 */
public void paintImmediately(int x, int y, int width, int height){
	RepaintManager repaintManager = null;
	boolean save = true;
	if (!isDoubleBuffered()) {
		repaintManager = RepaintManager.currentManager(this);
		save = repaintManager.isDoubleBufferingEnabled();
		repaintManager.setDoubleBufferingEnabled(false);
	}
	super.paintImmediately(x, y, width, height);

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