- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
JFrame in scala.swing
Thu, 2009-03-05, 00:02
I have an org.jfree.chart.ChartFrame which extends javax.swing.JFrame
and I want to display it using scala.swing. Is there some way I can make
this work?
http://www.jfree.org/jfreechart/api/javadoc/index.html
java.lang.Object
extended by java.awt.Component
extended by java.awt.Container
extended by java.awt.Window
extended by java.awt.Frame
extended by javax.swing.JFrame
extended by org.jfree.chart.ChartFrame
I'm hoping to display a pie chart in a BorderPanel.
Thanks!
Chas. Munat
Thu, 2009-03-05, 00:37
#2
Re: JFrame in scala.swing
Sorry to reply to my own message, but I figured it out. ChartFrame is a
JFrame, but JFrame is *not* a JComponent. However, JFreeCharts offers a
ChartPanel, which is a JPanel, thus a JComponent. A simple
Component.wrap(chart) and it works.
Somehow I thought it would be more difficult. Scala really kicks ass.
Thanks!
Chas. Munat
Charles F. Munat wrote:
> I have an org.jfree.chart.ChartFrame which extends javax.swing.JFrame
> and I want to display it using scala.swing. Is there some way I can make
> this work?
>
> http://www.jfree.org/jfreechart/api/javadoc/index.html
>
> java.lang.Object
> extended by java.awt.Component
> extended by java.awt.Container
> extended by java.awt.Window
> extended by java.awt.Frame
> extended by javax.swing.JFrame
> extended by org.jfree.chart.ChartFrame
>
> I'm hoping to display a pie chart in a BorderPanel.
>
> Thanks!
>
> Chas. Munat
Thu, 2009-03-05, 01:37
#3
Re: JFrame in scala.swing
On Wed, Mar 4, 2009 at 8:22 PM, Charles F. Munat <chas@munat.com> wrote:
Sorry to reply to my own message, but I figured it out. ChartFrame is a JFrame, but JFrame is *not* a JComponent. However, JFreeCharts offers a ChartPanel, which is a JPanel, thus a JComponent. A simple Component.wrap(chart) and it works.
One thing that may work is to create a scala.swing version ChartFrame. I may be wrong but a lot of the classes in scala.swing are components wrapping a JComponent or JFrame and adding a set of traits. It may actually be easy to get some class that inherits JFrame and add the traits and wrapping you need. Whenever in doubt I look at the scala.swing source for inspiration (and amazement) on how to do things.
Somehow I thought it would be more difficult. Scala really kicks ass.
Agreed, and I really like the scala.swing way of doing things.
Thomas
I am not sure I understand what you want to do and where the problem is.
I am not familiar with JFreeChart either. Could you elaborate?
Thanks
Ingo
Charles F. Munat wrote:
> I have an org.jfree.chart.ChartFrame which extends javax.swing.JFrame
> and I want to display it using scala.swing. Is there some way I can make
> this work?
>
> http://www.jfree.org/jfreechart/api/javadoc/index.html
>
> java.lang.Object
> extended by java.awt.Component
> extended by java.awt.Container
> extended by java.awt.Window
> extended by java.awt.Frame
> extended by javax.swing.JFrame
> extended by org.jfree.chart.ChartFrame
>
> I'm hoping to display a pie chart in a BorderPanel.
>
> Thanks!
>
> Chas. Munat