Java tutorial
//package com.java2s; /* * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ import sun.awt.AppContext; import javax.swing.JComponent; import javax.swing.RepaintManager; public class Main { /** * The {@code clientProperty} key for delegate {@code RepaintManager} */ private static final Object DELEGATE_REPAINT_MANAGER_KEY = new StringBuilder("DelegateRepaintManagerKey"); /** * 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); } }