Using Chart.J with Swing/jfc

Article ID: 1086
Last updated: 02 Feb, 2008
Article ID: 1086
Last updated: 02 Feb, 2008
Revision: 1
Views: 2728
Posted: 05 Oct, 1998
by Dean J.
Updated: 02 Feb, 2008
by Dean J.
Problem


Trying to compile the JFC examples using Swing/jfc results in errors like these:
Monitor.java:13: Class java.awt.swing.JApplet not found in import.
import java.awt.swing.JApplet;
^



Cause


Chart.J's JFC examples were built using the JDK 1.2 beta. Some of the path names and imports differ between the final version of JDK 1.2 and the version of Swing/jfc you are using.

Update

Current versions of StudioJ use the new javax.swing.* pathing instead of the older Swing version com.sun.java.swing.*.

If you need to change your code to use this new pathing, the PackageRenamer utility on Sun's website will help you automatically change all your import statements.

http://www.javasoft.com/products/jfc/PackageRenamer/index.html


Action


To change the libraries to correctly use the Swing paths, change the following:
  • In StudioJcom oguechartjfccorev2_2graphicsCanvas3D.java, the first few lines should look like this:
      import java.awt.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.Vector;
    //import java.awt.swing.JComponent; //comment this out
    import com.sun.java.swing.JComponent; // add this line
  • In StudioJcom oguechartjfcoverlayoverlaysv2_2chartsOverlayChart.java, the first few lines should look like this:
      import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Panel;
    import java.awt.Scrollbar;
    import java.awt.event.AdjustmentEvent;
    import java.awt.event.AdjustmentListener;

    //import java.awt.swing.JComponent; // comment this out
    import com.sun.java.swing.JComponent; //add this line

After making these changes, recompile these two files.

In the sample, you might also need to change the import line to look as follows:

  //import java.awt.swing.JApplet;   //comment this out
import com.sun.java.swing.JApplet; //add this line
import java.awt.*;

public class LineExample extends JApplet
This article was:   Helpful | Not helpful
Report an issue
Article ID: 1086
Last updated: 02 Feb, 2008
Revision: 1
Views: 2728
Posted: 05 Oct, 1998 by Dean J.
Updated: 02 Feb, 2008 by Dean J.

Others in this category