1 19 20 21 package org.netbeans.modules.form.fakepeer; 22 23 import java.awt.*; 24 25 29 30 public class FakePeerContainer extends Container 31 { 32 public FakePeerContainer() { 33 super(); 34 setFont(FakePeerSupport.getDefaultAWTFont()); 35 } 36 37 public void addNotify() { 38 FakePeerSupport.attachFakePeerRecursively(this); 39 super.addNotify(); 40 } 41 42 protected void addImpl(Component comp, Object constraints, int index) { 43 FakePeerSupport.attachFakePeer(comp); 44 super.addImpl(comp, constraints, index); 45 } 46 47 public void update(Graphics g) { 48 } 49 50 public void paint(Graphics g) { 51 Dimension sz = getSize(); 52 55 Color c = SystemColor.control; 56 g.setColor(c); 57 g.fillRect(0, 0, sz.width, sz.height); 58 60 super.paint(g); 61 paintFakePeersRecursively(g, this); 62 } 63 64 private static void paintFakePeersRecursively(Graphics g, Container container) { 65 if (!container.isVisible()) 66 return; 67 68 Component components[] = FakePeerSupport.getComponents(container); 69 int ncomponents = components.length; 70 71 Rectangle clip = g.getClipBounds(); 72 for (int i = 0; i < ncomponents; i++) { 73 Component comp = components[i]; 74 if (comp != null && 75 comp.getPeer() instanceof FakePeer && 76 comp.isVisible()) { 77 Rectangle cr = comp.getBounds(); 78 if ((clip == null) || cr.intersects(clip)) { 79 Graphics cg = g.create(cr.x, cr.y, cr.width, cr.height); 80 cg.setFont(comp.getFont()); 81 try { 82 comp.getPeer().paint(cg); 85 } 86 finally { 87 cg.dispose(); 88 } 89 } 90 } 91 if (comp instanceof Container) { 92 Rectangle cr = comp.getBounds(); 93 if ((clip == null) || cr.intersects(clip)) { 94 Graphics cg = g.create(cr.x, cr.y, cr.width, cr.height); 95 paintFakePeersRecursively(cg,(Container) comp); 96 cg.dispose(); 97 } 98 } 99 } 100 } 101 } 102 | Popular Tags |