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:
to
Run the application.
Regards,
tom