1 19 20 package org.netbeans.modules.welcome.content; 21 22 import java.awt.Dimension ; 23 import java.awt.Rectangle ; 24 import java.beans.PropertyChangeEvent ; 25 import javax.swing.JComponent ; 26 27 31 public abstract class RSSFeedReaderPanel extends ContentPanel { 32 33 34 public RSSFeedReaderPanel( String key, boolean showProxyButton ) { 35 super( BundleSupport.getLabel( key ) ); 36 setOpaque( true ); 37 setBackground( Utils.getColor(DEFAULT_BACKGROUND_COLOR) ); 38 setContent( buildContent( BundleSupport.getURL( key ), showProxyButton ) ); 39 } 40 41 protected JComponent buildContent( String url, boolean showProxyButton ) { 42 RSSFeed feed = new RSSFeed( url, showProxyButton ); 43 feed.addPropertyChangeListener( RSSFeed.FEED_CONTENT_PROPERTY, this ); 44 return feed; 45 } 46 47 public void setSize(Dimension d) { 48 if( d.width < FEED_PANEL_MIN_WIDTH || d.width > FEED_PANEL_MAX_WIDTH ) { 49 d = new Dimension ( d ); 50 if( d.width < FEED_PANEL_MIN_WIDTH ) 51 d.width = FEED_PANEL_MIN_WIDTH; 52 else 53 d.width = FEED_PANEL_MAX_WIDTH; 54 } 55 super.setSize(d); 56 } 57 58 public void setBounds(Rectangle r) { 59 if( r.width < FEED_PANEL_MIN_WIDTH || r.width > FEED_PANEL_MAX_WIDTH ) { 60 r = new Rectangle ( r ); 61 if( r.width < FEED_PANEL_MIN_WIDTH ) 62 r.width = FEED_PANEL_MIN_WIDTH; 63 else 64 r.width = FEED_PANEL_MAX_WIDTH; 65 } 66 super.setBounds(r); 67 } 68 69 public void setBounds(int x, int y, int width, int height) { 70 if( width < FEED_PANEL_MIN_WIDTH ) 71 width = FEED_PANEL_MIN_WIDTH; 72 else if( width > FEED_PANEL_MAX_WIDTH ) 73 width = FEED_PANEL_MAX_WIDTH; 74 super.setBounds(x, y, width, height); 75 } 76 77 public Dimension getPreferredSize() { 78 Dimension d = super.getPreferredSize(); 79 if( d.width < FEED_PANEL_MIN_WIDTH || d.width > FEED_PANEL_MAX_WIDTH ) { 80 d = new Dimension ( d ); 81 if( d.width < FEED_PANEL_MIN_WIDTH ) 82 d.width = FEED_PANEL_MIN_WIDTH; 83 else 84 d.width = FEED_PANEL_MAX_WIDTH; 85 } 86 return d; 87 } 88 89 protected void feedContentLoaded() { 90 91 } 92 93 public void propertyChange(PropertyChangeEvent evt) { 94 if( RSSFeed.FEED_CONTENT_PROPERTY.equals( evt.getPropertyName() ) ) { 95 feedContentLoaded(); 96 } else { 97 super.propertyChange( evt ); 98 } 99 100 } 101 } 102 | Popular Tags |