1 7 package javax.swing.text.html; 8 9 import java.awt.*; 10 import java.awt.event.*; 11 import java.io.*; 12 import java.net.MalformedURLException ; 13 import java.net.URL ; 14 import javax.swing.text.*; 15 import javax.swing.*; 16 import javax.swing.border.*; 17 import javax.swing.event.*; 18 import java.util.*; 19 20 28 class EditableView extends ComponentView { 29 30 EditableView(Element e) { 31 super(e); 32 } 33 34 public float getMinimumSpan(int axis) { 35 if (isVisible) { 36 return super.getMinimumSpan(axis); 37 } 38 return 0; 39 } 40 41 public float getPreferredSpan(int axis) { 42 if (isVisible) { 43 return super.getPreferredSpan(axis); 44 } 45 return 0; 46 } 47 48 public float getMaximumSpan(int axis) { 49 if (isVisible) { 50 return super.getMaximumSpan(axis); 51 } 52 return 0; 53 } 54 55 public void paint(Graphics g, Shape allocation) { 56 Component c = getComponent(); 57 Container host = getContainer(); 58 59 if (host != null && 60 isVisible != ((JTextComponent)host).isEditable()) { 61 isVisible = ((JTextComponent)host).isEditable(); 62 preferenceChanged(null, true, true); 63 host.repaint(); 64 } 65 76 if (isVisible) { 77 super.paint(g, allocation); 78 } 79 else { 80 setSize(0, 0); 81 } 82 if (c != null) { 83 c.setFocusable(isVisible); 84 } 85 } 86 87 public void setParent(View parent) { 88 if (parent != null) { 89 Container host = parent.getContainer(); 90 if (host != null) { 91 isVisible = ((JTextComponent)host).isEditable(); 92 } 93 } 94 super.setParent(parent); 95 } 96 97 100 public boolean isVisible() { 101 return isVisible; 102 } 103 104 106 private boolean isVisible; 107 } | Popular Tags |