42 import java.awt.Dimension; 43 import java.awt.Rectangle; 44 import java.awt.Insets; 45 import java.awt.Color; 46 import java.awt.Graphics; 47 import java.awt.Font; 48 import java.awt.FontMetrics; 49 import java.beans.PropertyChangeEvent; 50 import java.beans.PropertyChangeListener; 51 52 /** 53 * A Windows L&F implementation of LabelUI. This implementation 54 * is completely static, i.e. there's only one UIView implementation 55 * that's shared by all JLabel objects. 56 * 57 * @author Hans Muller 58 */ 59 public class BasicLabelUI extends LabelUI implements PropertyChangeListener 60 { 61 /** 62 * The default <code>BasicLabelUI</code> instance. This field might 63 * not be used. To change the default instance use a subclass which 64 * overrides the <code>createUI</code> method, and place that class 65 * name in defaults table under the key "LabelUI". 66 */ 67 protected static BasicLabelUI labelUI = new BasicLabelUI(); 68 private static final Object BASIC_LABEL_UI_KEY = new Object(); 69 70 private Rectangle paintIconR = new Rectangle(); 71 private Rectangle paintTextR = new Rectangle(); 72 73 static void loadActionMap(LazyActionMap map) { 74 map.put(new Actions(Actions.PRESS)); 75 map.put(new Actions(Actions.RELEASE)); 76 } 77 78 /** 79 * Forwards the call to SwingUtilities.layoutCompoundLabel(). 80 * This method is here so that a subclass could do Label specific 81 * layout and to shorten the method name a little. 82 * 83 * @param label an instance of {@code JLabel} 84 * @param fontMetrics a font metrics | 42 import java.awt.Dimension; 43 import java.awt.Rectangle; 44 import java.awt.Insets; 45 import java.awt.Color; 46 import java.awt.Graphics; 47 import java.awt.Font; 48 import java.awt.FontMetrics; 49 import java.beans.PropertyChangeEvent; 50 import java.beans.PropertyChangeListener; 51 52 /** 53 * A Windows L&F implementation of LabelUI. This implementation 54 * is completely static, i.e. there's only one UIView implementation 55 * that's shared by all JLabel objects. 56 * 57 * @author Hans Muller 58 */ 59 public class BasicLabelUI extends LabelUI implements PropertyChangeListener 60 { 61 /** 62 * The default {@code BasicLabelUI} instance. This field might 63 * not be used. To change the default instance use a subclass which 64 * overrides the {@code createUI} method, and place that class 65 * name in defaults table under the key "LabelUI". 66 */ 67 protected static BasicLabelUI labelUI = new BasicLabelUI(); 68 private static final Object BASIC_LABEL_UI_KEY = new Object(); 69 70 private Rectangle paintIconR = new Rectangle(); 71 private Rectangle paintTextR = new Rectangle(); 72 73 static void loadActionMap(LazyActionMap map) { 74 map.put(new Actions(Actions.PRESS)); 75 map.put(new Actions(Actions.RELEASE)); 76 } 77 78 /** 79 * Forwards the call to SwingUtilities.layoutCompoundLabel(). 80 * This method is here so that a subclass could do Label specific 81 * layout and to shorten the method name a little. 82 * 83 * @param label an instance of {@code JLabel} 84 * @param fontMetrics a font metrics |