KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > welcome > content > RSSFeedReaderPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.welcome.content;
21
22 import java.awt.Dimension JavaDoc;
23 import java.awt.Rectangle JavaDoc;
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import javax.swing.JComponent JavaDoc;
26
27 /**
28  *
29  * @author S. Aubrecht
30  */

31 public abstract class RSSFeedReaderPanel extends ContentPanel {
32
33     /** Creates a new instance of AbstractFeedReaderPanel */
34     public RSSFeedReaderPanel( String JavaDoc 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 JavaDoc buildContent( String JavaDoc 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 JavaDoc d) {
48         if( d.width < FEED_PANEL_MIN_WIDTH || d.width > FEED_PANEL_MAX_WIDTH ) {
49             d = new Dimension JavaDoc( 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 JavaDoc r) {
59         if( r.width < FEED_PANEL_MIN_WIDTH || r.width > FEED_PANEL_MAX_WIDTH ) {
60             r = new Rectangle JavaDoc( 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 JavaDoc getPreferredSize() {
78         Dimension JavaDoc d = super.getPreferredSize();
79         if( d.width < FEED_PANEL_MIN_WIDTH || d.width > FEED_PANEL_MAX_WIDTH ) {
80             d = new Dimension JavaDoc( 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 JavaDoc 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