1 7 package javax.swing; 8 9 import java.awt.*; 10 import java.awt.event.*; 11 import java.io.*; 12 import java.beans.PropertyChangeListener ; 13 import java.util.Locale ; 14 import java.util.Vector ; 15 16 import javax.accessibility.*; 17 18 49 public class CellRendererPane extends Container implements Accessible 50 { 51 54 public CellRendererPane() { 55 super(); 56 setLayout(null); 57 setVisible(false); 58 } 59 60 64 public void invalidate() { } 65 66 67 70 public void paint(Graphics g) { } 71 72 73 76 public void update(Graphics g) { } 77 78 79 84 protected void addImpl(Component x, Object constraints, int index) { 85 if (x.getParent() == this) { 86 return; 87 } 88 else { 89 super.addImpl(x, constraints, index); 90 } 91 } 92 93 94 105 public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) { 106 if (c == null) { 107 if (p != null) { 108 Color oldColor = g.getColor(); 109 g.setColor(p.getBackground()); 110 g.fillRect(x, y, w, h); 111 g.setColor(oldColor); 112 } 113 return; 114 } 115 116 if (c.getParent() != this) { 117 this.add(c); 118 } 119 120 c.setBounds(x, y, w, h); 121 122 if(shouldValidate) { 123 c.validate(); 124 } 125 126 boolean wasDoubleBuffered = false; 127 if ((c instanceof JComponent ) && ((JComponent )c).isDoubleBuffered()) { 128 wasDoubleBuffered = true; 129 ((JComponent )c).setDoubleBuffered(false); 130 } 131 132 Graphics cg = g.create(x, y, w, h); 133 try { 134 c.paint(cg); 135 } 136 finally { 137 cg.dispose(); 138 } 139 140 if (wasDoubleBuffered && (c instanceof JComponent )) { 141 ((JComponent )c).setDoubleBuffered(true); 142 } 143 144 c.setBounds(-w, -h, 0, 0); 145 } 146 147 148 151 public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) { 152 paintComponent(g, c, p, x, y, w, h, false); 153 } 154 155 156 159 public void paintComponent(Graphics g, Component c, Container p, Rectangle r) { 160 paintComponent(g, c, p, r.x, r.y, r.width, r.height); 161 } 162 163 164 private void writeObject(ObjectOutputStream s) throws IOException { 165 removeAll(); 166 s.defaultWriteObject(); 167 } 168 169 170 174 protected AccessibleContext accessibleContext = null; 175 176 185 public AccessibleContext getAccessibleContext() { 186 if (accessibleContext == null) { 187 accessibleContext = new AccessibleCellRendererPane(); 188 } 189 return accessibleContext; 190 } 191 192 196 protected class AccessibleCellRendererPane extends AccessibleAWTContainer { 197 206 public AccessibleRole getAccessibleRole() { 207 return AccessibleRole.PANEL; 208 } 209 } } 211 212 213 | Popular Tags |