001package org.jdesktop.swingx.plaf; 002 003import java.beans.PropertyChangeListener; 004import java.util.Map; 005import java.util.WeakHashMap; 006 007import javax.swing.JComponent; 008 009@SuppressWarnings("nls") 010public abstract class AbstractUIChangeHandler implements PropertyChangeListener { 011 //prevent double installation. 012 private final Map<JComponent, Boolean> installed = new WeakHashMap<JComponent, Boolean>(); 013 014 public void install(JComponent c){ 015 if(isInstalled(c)){ 016 return; 017 } 018 019 c.addPropertyChangeListener("UI", this); 020 installed.put(c, Boolean.FALSE); 021 } 022 023 public boolean isInstalled(JComponent c) { 024 return installed.containsKey(c); 025 } 026 027 public void uninstall(JComponent c){ 028 c.removePropertyChangeListener("UI", this); 029 installed.remove(c); 030 } 031}