TChart not working in JBuilder7

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
JT
Newbie
Newbie
Posts: 7
Joined: Fri Jun 29, 2007 12:00 am

TChart not working in JBuilder7

Post by JT » Wed Sep 05, 2007 7:21 pm

I have the following problem with TeeChart and JBuilder7: If I paste the following example code (eg from the Intro in the tutorial)

Series bar = new Bar(tChart1.getChart());
tChart1.getAxes().getBottom().setIncrement(1);
bar.add(400, "pears", Color.Green);
bar.add(500, "apples", Color.Red);
bar.add(400, "bananas", Color.Yellow);
bar.add(200, "oranges", Color.Orange);

inside a command button (with Action Listener) or somewhere else in the code of the visual interface JBuilder does not recognize eg 'Series' or 'bar' as a class (message: "cannot resolve to a type...."). I thought the classes are known with the command

import com.steema.teechart.TChart;

which is automatically pasted in when the TChart is put onto the visual interface. I have to say that I was only able to install TeeChart as a netbeans and do not have a TChart icon in the component palette.

Can somebody help me???








Finally I have managed to install TChart in the JBuilder 7 IDE (though I was not able to

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Wed Sep 05, 2007 11:03 pm

It looks like JBuilder isn't able to find the teeChart jar library:
* Have you added this library to JBuilder?
* Did you include this library to your project?

If JBuilder doesn't know about the library (or it isn't told that the project needs to use the library, then it isn't able to understand com.steema.teechart.TChart, hence the resolve message.

JT
Newbie
Newbie
Posts: 7
Joined: Fri Jun 29, 2007 12:00 am

Post by JT » Thu Sep 06, 2007 7:11 pm

Hi,
First of all thanks for your quick reply. I checked under
project properties>>Bean InfoPath>>Bean Infoclasses and
Java BuildPath>>Libraries
and in both cases the TeeChart.Swing.jar is listed. By the way, is this the correct file? However, I could not find "com.steema.teechart.Tchart.jar" in any JBuilder folder. Do I need this? Into which folder should I copy this? Also, what I noticed is that for each project I create I have to add the TeeChart as a netbean again. TeeChart does not appear as a permanent button in the palette. How do I install it permanently?

Thanks for your help,
Joerg

JT
Newbie
Newbie
Posts: 7
Joined: Fri Jun 29, 2007 12:00 am

Post by JT » Fri Sep 07, 2007 11:55 am

Hi,
please note this addition to my last reply: JBuilder finds import com.steema.teechart.TChart; it was just outside the program folder (when I remove it, Tchart will disappear from the form where i pasted it). So, according to this JBuilder should be able to the read eg the Series class or other since it is able to retreive com.steema.teechart.TChart. Do I misunderstand something. Please help. Thanks again!
-Joerg

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Sun Sep 09, 2007 2:40 pm

Hi,

Please follow the following steps to use JTeeChart in your JBuilder2007 projects.

A. Create Library
-----------------

In Window / Preferences:

Select Java > Build Path > User Libraries to open the library manager dialog

Click 'New' > Provide a name (eg. 'JTeeChart')
Click 'OK'

Select the newly added library
Click 'Add JARs...'
Browse to the jar 'TeeChart.Swing.jar'
Click 'Open'
Click 'OK' to close the library manager dialog


B. Using components in the Visual Editor
----------------------------------------

After step A. you can use JTeeChart inside your project:

Go to the properties page of the project (Project / Properties)
Select 'Java Build Path' and go to the 'Libraries' tab.
Click 'Add Library'
Select 'User Library
Click 'Next'
Check 'JTeeChart' library (created at step A)
Click 'Finish'
Click 'OK' to close the Project Properties dialog

You can also use the teeChart widgets from the Visual Editor:
Go to the Bean Palette and select 'Choose Bean' to open the 'Choose a bean' dialog
Enter the bean you are looking for, eg TChart
Select the TChart - com.steema.teechart bean and click 'OK'
The dialog has a history list, which shows the recent used beans

To have the widgets appear in the palette, you need to write a plug-in. (For now we refer to the eclipse and JBuilder documentation, a futher release of JTeeChart might include a plugin)

If you follow the above steps, you should be able to use JTeeChart in your JBuilder2007 projects. You can try the following tests:

1. Project without Visual Builder:
(Create a new project and add the JTeeChart library to it, see step B)

add following class to it and run the project:

Code: Select all

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import com.steema.teechart.TChart;


public class Application {
    /**
     * Construct and show the application.
     */
    public Application() {
        JFrame frame = new JFrame();
    	
        TChart chart = new TChart();
        
        frame.add(chart);
        
        frame.pack();
        
        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
                System.exit(0);
            }
        });        
        
        // Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
    }
	/**
	 * @param args
	 */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (Exception exception) {
                    exception.printStackTrace();
                }

                new Application();
            }
        });
    }	
}
2. Project with Visual Builder:

Add a new JFrame class to the project, named MainFrame. In the Visual Editor, use 'Choose Bean' to search for the TChart widget. Click on 'OK' to add the widget to your frame. The code should look like:

Code: Select all

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import com.steema.teechart.TChart;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private TChart tChart = null;

	/**
	 * This is the default constructor
	 */
	public MainFrame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 200);
		this.setContentPane(getJContentPane());
		this.setTitle("Test");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getTChart(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes tChart	
	 * 	
	 * @return com.steema.teechart.TChart	
	 */
	private TChart getTChart() {
		if (tChart == null) {
			tChart = new TChart();
			tChart.setName("Test");
		}
		return tChart;
	}

}
Change the Application class code:

Code: Select all

JFrame frame = new JFrame();
to

Code: Select all

JFrame frame = new MainFrame();
Run the application.

Regards,
tom

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Re: TChart not working in JBuilder7

Post by tom » Mon Sep 10, 2007 9:51 pm

7664818 wrote:JBuilder does not recognize eg 'Series' or 'bar' as a class (message: "cannot resolve to a type....").
Have you organised your imports after pasting the code?

Using import com.steema.teechart.TChart; won't be enough.

After pasting the code, you should add the following as well:

import com.steema.teechart.drawing.Color;
import com.steema.teechart.styles.Bar;
import com.steema.teechart.styles.Series;

PS. It should be Color.GREEN, Color.RED, Color.YELLOW, ... when using the Color class of teechart.

Regards,
tom

JT
Newbie
Newbie
Posts: 7
Joined: Fri Jun 29, 2007 12:00 am

Post by JT » Mon Sep 10, 2007 10:44 pm

Thanks! Tom, you saved my life (-;

Post Reply