1 7 8 package javax.swing.plaf.synth; 9 10 import java.awt.*; 11 import java.awt.event.ActionEvent ; 12 import java.beans.PropertyChangeEvent ; 13 import java.beans.PropertyChangeListener ; 14 import javax.swing.*; 15 import javax.swing.plaf.*; 16 import javax.swing.plaf.basic.BasicRootPaneUI ; 17 import sun.swing.plaf.synth.SynthUI; 18 19 25 class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { 26 private SynthStyle style; 27 28 public static ComponentUI createUI(JComponent c) { 29 return new SynthRootPaneUI (); 30 } 31 32 protected void installDefaults(JRootPane c){ 33 updateStyle(c); 34 } 35 36 protected void uninstallDefaults(JRootPane root) { 37 SynthContext context = getContext(root, ENABLED); 38 39 style.uninstallDefaults(context); 40 context.dispose(); 41 style = null; 42 } 43 44 public SynthContext getContext(JComponent c) { 45 return getContext(c, getComponentState(c)); 46 } 47 48 private SynthContext getContext(JComponent c, int state) { 49 return SynthContext.getContext(SynthContext .class, c, 50 SynthLookAndFeel.getRegion(c), style, state); 51 } 52 53 private Region getRegion(JComponent c) { 54 return SynthLookAndFeel.getRegion(c); 55 } 56 57 private int getComponentState(JComponent c) { 58 return SynthLookAndFeel.getComponentState(c); 59 } 60 61 private void updateStyle(JComponent c) { 62 SynthContext context = getContext(c, ENABLED); 63 SynthStyle oldStyle = style; 64 style = SynthLookAndFeel.updateStyle(context, this); 65 if (style != oldStyle) { 66 if (oldStyle != null) { 67 uninstallKeyboardActions((JRootPane)c); 68 installKeyboardActions((JRootPane)c); 69 } 70 } 71 context.dispose(); 72 } 73 74 public void update(Graphics g, JComponent c) { 75 SynthContext context = getContext(c); 76 77 SynthLookAndFeel.update(context, g); 78 context.getPainter().paintRootPaneBackground(context, 79 g, 0, 0, c.getWidth(), c.getHeight()); 80 paint(context, g); 81 context.dispose(); 82 } 83 84 public void paint(Graphics g, JComponent c) { 85 SynthContext context = getContext(c); 86 87 paint(context, g); 88 context.dispose(); 89 } 90 91 protected void paint(SynthContext context, Graphics g) { 92 } 93 94 public void paintBorder(SynthContext context, Graphics g, int x, 95 int y, int w, int h) { 96 context.getPainter().paintRootPaneBorder(context, g, x, y, w, h); 97 } 98 99 104 public void propertyChange(PropertyChangeEvent e) { 105 if (SynthLookAndFeel.shouldUpdateStyle(e)) { 106 updateStyle((JRootPane)e.getSource()); 107 } 108 super.propertyChange(e); 109 } 110 } 111 | Popular Tags |