KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > ChartFrame


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * ---------------
27  * ChartFrame.java
28  * ---------------
29  * (C) Copyright 2001-2005, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: ChartFrame.java,v 1.3 2005/02/04 09:22:09 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 22-Nov-2001 : Version 1 (DG);
39  * 08-Jan-2001 : Added chartPanel attribute (DG);
40  * 24-May-2002 : Renamed JFreeChartFrame --> ChartFrame (DG);
41  *
42  */

43
44 package org.jfree.chart;
45
46 import javax.swing.JFrame JavaDoc;
47 import javax.swing.JScrollPane JavaDoc;
48 import javax.swing.WindowConstants JavaDoc;
49
50 /**
51  * A frame for displaying a chart.
52  */

53 public class ChartFrame extends JFrame JavaDoc {
54
55     /** The chart panel. */
56     private ChartPanel chartPanel;
57
58     /**
59      * Constructs a frame for a chart.
60      *
61      * @param title the frame title.
62      * @param chart the chart.
63      */

64     public ChartFrame(String JavaDoc title, JFreeChart chart) {
65         this(title, chart, false);
66     }
67
68     /**
69      * Constructs a frame for a chart.
70      *
71      * @param title the frame title.
72      * @param chart the chart.
73      * @param scrollPane if <code>true</code>, put the Chart(Panel) into a
74      * JScrollPane.
75      */

76     public ChartFrame(String JavaDoc title, JFreeChart chart, boolean scrollPane) {
77         super(title);
78         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
79         this.chartPanel = new ChartPanel(chart);
80         if (scrollPane) {
81             setContentPane(new JScrollPane JavaDoc(this.chartPanel));
82         }
83         else {
84             setContentPane(this.chartPanel);
85         }
86     }
87
88     /**
89      * Returns the chart panel for the frame.
90      *
91      * @return The chart panel.
92      */

93     public ChartPanel getChartPanel() {
94         return this.chartPanel;
95     }
96
97 }
98
Popular Tags