1 7 8 package javax.swing.plaf.synth; 9 10 import javax.swing.*; 11 import javax.swing.text.*; 12 import javax.swing.event.*; 13 import javax.swing.plaf.*; 14 import javax.swing.plaf.basic.BasicTextAreaUI ; 15 import java.awt.*; 16 import java.beans.PropertyChangeEvent ; 17 import sun.swing.plaf.synth.SynthUI; 18 19 36 class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { 37 private SynthStyle style; 38 39 45 public static ComponentUI createUI(JComponent ta) { 46 return new SynthTextAreaUI (); 47 } 48 49 protected void installDefaults() { 50 updateStyle((JTextComponent)getComponent()); 51 } 52 53 protected void uninstallDefaults() { 54 SynthContext context = getContext(getComponent(), ENABLED); 55 56 getComponent().putClientProperty("caretAspectRatio", null); 57 58 style.uninstallDefaults(context); 59 context.dispose(); 60 style = null; 61 super.uninstallDefaults(); 62 } 63 64 public void installUI(JComponent c) { 65 super.installUI(c); 66 } 67 68 private void updateStyle(JTextComponent comp) { 69 SynthContext context = getContext(comp, ENABLED); 70 SynthStyle oldStyle = style; 71 72 style = SynthLookAndFeel.updateStyle(context, this); 73 74 if (style != oldStyle) { 75 SynthTextFieldUI.updateStyle(comp, context, getPropertyPrefix()); 76 77 if (oldStyle != null) { 78 uninstallKeyboardActions(); 79 installKeyboardActions(); 80 } 81 } 82 context.dispose(); 83 } 84 85 public SynthContext getContext(JComponent c) { 86 return getContext(c, getComponentState(c)); 87 } 88 89 private SynthContext getContext(JComponent c, int state) { 90 return SynthContext.getContext(SynthContext .class, c, 91 SynthLookAndFeel.getRegion(c), style, state); 92 } 93 94 private int getComponentState(JComponent c) { 95 return SynthLookAndFeel.getComponentState(c); 96 } 97 98 public void update(Graphics g, JComponent c) { 99 SynthContext context = getContext(c); 100 101 SynthLookAndFeel.update(context, g); 102 context.getPainter().paintTextAreaBackground(context, 103 g, 0, 0, c.getWidth(), c.getHeight()); 104 paint(context, g); 105 context.dispose(); 106 } 107 108 protected void paint(SynthContext context, Graphics g) { 109 super.paint(g, getComponent()); 110 } 111 112 protected void paintBackground(Graphics g) { 113 } 115 116 public void paintBorder(SynthContext context, Graphics g, int x, 117 int y, int w, int h) { 118 context.getPainter().paintTextAreaBorder(context, g, x, y, w, h); 119 } 120 121 131 protected void propertyChange(PropertyChangeEvent evt) { 132 if (SynthLookAndFeel.shouldUpdateStyle(evt)) { 133 updateStyle((JTextComponent)evt.getSource()); 134 } 135 super.propertyChange(evt); 136 } 137 } 138 | Popular Tags |