1 7 package javax.swing.text.html; 8 9 import javax.swing.text.*; 10 import java.awt.*; 11 12 21 class NoFramesView extends BlockView { 22 23 32 public NoFramesView(Element elem, int axis) { 33 super(elem, axis); 34 visible = false; 35 } 36 37 38 47 public void paint(Graphics g, Shape allocation) { 48 Container host = getContainer(); 49 if (host != null && 50 visible != ((JTextComponent)host).isEditable()) { 51 visible = ((JTextComponent)host).isEditable(); 52 } 53 54 if (!isVisible()) { 55 return; 56 } 57 super.paint(g, allocation); 58 } 59 60 61 71 public void setParent(View p) { 72 if (p != null) { 73 Container host = p.getContainer(); 74 if (host != null) { 75 visible = ((JTextComponent)host).isEditable(); 76 } 77 } 78 super.setParent(p); 79 } 80 81 85 public boolean isVisible() { 86 return visible; 87 } 88 89 90 94 protected void layout(int width, int height) { 95 if (!isVisible()) { 96 return; 97 } 98 super.layout(width, height); 99 } 100 101 114 public float getPreferredSpan(int axis) { 115 if (!visible) { 116 return 0; 117 } 118 return super.getPreferredSpan(axis); 119 } 120 121 131 public float getMinimumSpan(int axis) { 132 if (!visible) { 133 return 0; 134 } 135 return super.getMinimumSpan(axis); 136 } 137 138 148 public float getMaximumSpan(int axis) { 149 if (!visible) { 150 return 0; 151 } 152 return super.getMaximumSpan(axis); 153 } 154 155 boolean visible; 156 } 157 | Popular Tags |