1 30 31 package com.jgoodies.looks.common; 32 33 import java.awt.Component ; 34 35 import javax.swing.LookAndFeel ; 36 import javax.swing.Popup ; 37 import javax.swing.PopupFactory ; 38 39 import com.jgoodies.looks.Options; 40 41 42 70 public final class ShadowPopupFactory extends PopupFactory { 71 72 81 static final String PROP_HORIZONTAL_BACKGROUND = "jgoodies.hShadowBg"; 82 static final String PROP_VERTICAL_BACKGROUND = "jgoodies.vShadowBg"; 83 84 89 private final PopupFactory storedFactory; 90 91 92 94 private ShadowPopupFactory(PopupFactory storedFactory) { 95 this.storedFactory = storedFactory; 96 } 97 98 99 101 108 public static void install() { 109 PopupFactory factory = PopupFactory.getSharedInstance(); 110 if (factory instanceof ShadowPopupFactory) 111 return; 112 113 PopupFactory.setSharedInstance(new ShadowPopupFactory(factory)); 114 } 115 116 122 public static void uninstall() { 123 PopupFactory factory = PopupFactory.getSharedInstance(); 124 if (!(factory instanceof ShadowPopupFactory)) 125 return; 126 127 PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory; 128 PopupFactory.setSharedInstance(stored); 129 } 130 131 132 133 public Popup getPopup(Component owner, Component contents, int x, int y) 134 throws IllegalArgumentException { 135 Popup popup = storedFactory.getPopup(owner, contents, x, y); 136 return Options.isPopupDropShadowActive() 137 ? ShadowPopup.getInstance(owner, contents, x, y, popup) 138 : popup; 139 } 140 141 } 142 | Popular Tags |