Problemas em construir o projeto principal no Net Beans quando uso a bibilo J Free Chart e J Common

0 respostas
F

Eu importei as biblios J free Chart e J Common pro net beans para poder executar o exemplo abaixo,
no Net beans funcionou direitinho, depois eu construi o projeto principal no Net beans,gerando assim o
arquivo executável *.jar que fica na pasta …/dist. Entretando quando eu clico nele para que seja executado
aparece a seguinte mensagem:

"
Java Virtual Machine Laucher
Failed to load Main Class atribute from C:\Documents and Settings\Fernando\Meus documentos\Fernando\JAVA\teste\graph\dist "

Será que é alguma incompatibilidade com a versão do JDK ou coisa parecida?? a minha versão é essa
jdk-6-rc-bin-b104-windows-i586-01_nov_2006.

Se alguém puder dar um help ajudaria muitíssimo.

Abraços

Segue o código do gráfico:

import java.awt.Color;

import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;

import org.jfree.chart.ChartPanel;

import org.jfree.chart.JFreeChart;

import org.jfree.chart.axis.NumberAxis;

import org.jfree.chart.plot.PlotOrientation;

import org.jfree.chart.plot.XYPlot;

import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;

import org.jfree.data.function.Function2D;

import org.jfree.data.general.DatasetUtilities;

import org.jfree.data.xy.XYDataset;

import org.jfree.ui.ApplicationFrame;

import org.jfree.ui.RectangleInsets;

import org.jfree.ui.RefineryUtilities;

public class FunctionDemo1 extends ApplicationFrame {

public FunctionDemo1(String title) {

super(title);

JPanel chartPanel = createDemoPanel();

chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // tamanho do gráfico

setContentPane(chartPanel);

}
private static XYDataset createDataset1() {

Function2D f1 = new Function2D() {

public double getValue(double x) {

return 30*x;

}

};

return DatasetUtilities.sampleFunction2D(f1,-4.0, 2.5, 100,f1);//intervalo de x [-4.0; 2.5]

}
private static XYDataset createDataset2() {

Function2D f2 = new Function2D() {

public double getValue(double x) {

return 50 - 50 * x * x;

}

};

return DatasetUtilities.sampleFunction2D(f2, -2.0, 2.0, 300, f2);

}

private static JFreeChart createChart(XYDataset dataset1, XYDataset dataset2) {
// create the chart…
JFreeChart chart = ChartFactory.createXYLineChart(
“Gráfico Exemplo : Teste Exemplo”,// título do Grágico
“X”, // x axis label
“Y”, // y axis label

dataset1,
PlotOrientation.VERTICAL,
true,
true,
false
);

// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART…

chart.setBackgroundPaint(Color.white);

// get a reference to the plot for further customisation…

XYPlot plot = (XYPlot) chart.getPlot();

plot.setDataset(1, dataset2);

plot.setBackgroundPaint(Color.BLACK);

plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

plot.setDomainGridlinePaint(Color.white);

plot.setRangeGridlinePaint(Color.white);

//XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
//renderer.setShapesVisible(false);

XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
plot.setRenderer(1, renderer2);

// change the auto tick unit selection to integer units only…

NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

// OPTIONAL CUSTOMISATION COMPLETED.

return chart;
}

public static JPanel createDemoPanel() {

JFreeChart chart = createChart(createDataset1(), createDataset2());

return new ChartPanel(chart);

}
public static void main(String[] args) {

FunctionDemo1 demo = new FunctionDemo1(Function Demo 1);

demo.pack();

RefineryUtilities.centerFrameOnScreen(demo);// centraliza o gráfico na tela

demo.setVisible(true);

}

}

Criado 5 de março de 2008
Respostas 0
Participantes 1