1 27 package org.htmlparser.beans; 28 29 import java.awt.Dimension ; 30 import java.awt.FontMetrics ; 31 import java.beans.PropertyChangeEvent ; 32 import java.beans.PropertyChangeListener ; 33 import java.io.Serializable ; 34 import java.net.URL ; 35 import java.net.URLConnection ; 36 37 import javax.swing.JList ; 38 39 44 public class HTMLLinkBean extends JList implements Serializable , PropertyChangeListener 45 { 46 49 protected LinkBean mBean; 50 51 55 public HTMLLinkBean () 56 { 57 getBean ().addPropertyChangeListener (this); 58 } 59 60 65 protected LinkBean getBean () 66 { 67 if (null == mBean) 68 mBean = new LinkBean (); 69 70 return (mBean); 71 } 72 73 76 public Dimension getMinimumSize () 77 { 78 FontMetrics metrics; 79 int width; 80 int height; 81 82 metrics = getFontMetrics (getFont ()); 83 width = metrics.stringWidth ("http://localhost"); 84 height = metrics.getLeading () + metrics.getHeight () + metrics.getDescent (); 85 86 return (new Dimension (width, height)); 87 } 88 89 95 public void addPropertyChangeListener (PropertyChangeListener listener) 96 { 97 super.addPropertyChangeListener (listener); 98 getBean ().addPropertyChangeListener (listener); 99 } 100 101 107 public void removePropertyChangeListener (PropertyChangeListener listener) 108 { 109 super.addPropertyChangeListener (listener); 110 getBean ().removePropertyChangeListener (listener); 111 } 112 113 117 122 public URL [] getLinks () 123 { 124 return (getBean ().getLinks ()); 125 } 126 127 132 public String getURL () 133 { 134 return (getBean ().getURL ()); 135 } 136 137 142 public void setURL (String url) 143 { 144 getBean ().setURL (url); 145 } 146 147 151 public URLConnection getConnection () 152 { 153 return (getBean ().getConnection ()); 154 } 155 156 160 public void setConnection (URLConnection connection) 161 { 162 getBean ().setConnection (connection); 163 } 164 165 169 173 public void propertyChange (PropertyChangeEvent event) 174 { 175 if (event.getPropertyName ().equals (LinkBean.PROP_LINKS_PROPERTY)) 176 { 177 setListData (getBean ().getLinks ()); 178 } 179 } 180 181 } 204 205 206 207 | Popular Tags |