segue abaixo meu codigo
import org.jCharts.axisChart.customRenderers.axisValue.renderers.ValueLabelPosition;
import org.jCharts.axisChart.customRenderers.axisValue.renderers.ValueLabelRenderer;
import org.jCharts.chartData.AxisChartDataSet;
import org.jCharts.chartData.ChartDataException;
import org.jCharts.chartData.DataSeries;
//import org.jCharts.imageMap.ImageMap;
import org.jCharts.properties.*;
import org.jCharts.axisChart.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import org.jCharts.types.ChartType;
/**
*
* @author rodrigo.sm
*/
public class BarDemo extends JFrame {
private JPanel panel;
public BarDemo() throws ChartDataException, PropertyException {
inicializaPanel();
mostraGrafico();
}
private void inicializaPanel() throws ChartDataException, PropertyException{
this.setSize(1024,768);
this.panel = new JPanel(true);
this.panel.setSize(1024,768);
this.getContentPane().add(this.panel);
addWindowListener( new java.awt.event.WindowAdapter()
{
public void windowClosing( WindowEvent windowEvent )
{
exitForm( windowEvent );
}
}
);
}
private AxisChart montaGrafico() throws ChartDataException, PropertyException {
String[] xRotulo = {"1","2","3","4","5","6","7"};
String xTitulo = "Valor";
String yTitulo = "Y";
String Titulo = "Teste";
DataSeries dataSeries = new DataSeries (xRotulo, xTitulo,yTitulo,Titulo);
double[][] dados = new double[][]{{10,50,55,22,37,69,82},{50,22,80,64,120,10,40}};
String[] legenda = {"Barra 1","Barra 2"};
Paint[] cores = new Paint[]{Color.cyan, Color.RED};
ClusteredBarChartProperties clusteredBarChartProperties = new ClusteredBarChartProperties();
ValueLabelRenderer valueLabelRenderer = new ValueLabelRenderer( false, false, true, -1 );
valueLabelRenderer.setValueLabelPosition( ValueLabelPosition.ON_TOP );
valueLabelRenderer.useVerticalLabels( false );
clusteredBarChartProperties.addPostRenderEventListener( valueLabelRenderer );
AxisChartDataSet axisChartDataSet = new AxisChartDataSet(dados,legenda, cores, ChartType.BAR_CLUSTERED,clusteredBarChartProperties);
dataSeries.addIAxisPlotDataSet(axisChartDataSet);
AxisChart axisChart = new AxisChart(dataSeries, new ChartProperties(), new AxisProperties(), new LegendProperties(),1020,720);
return axisChart;
}
public void mostraGrafico () throws ChartDataException, PropertyException{
AxisChart grafico = montaGrafico();
BufferedImage bufferedImage = new BufferedImage( 1020, 720, BufferedImage.TYPE_INT_RGB );
Graphics2D graf = bufferedImage.createGraphics();
grafico.setGraphics2D( bufferedImage.createGraphics() );
grafico.render();
this.setVisible(true);
this.panel.getGraphics().drawImage( bufferedImage, 0, 0, this );
}
private void exitForm( WindowEvent windowEvent ){
System.exit( 0 );
}
public static void main( String args[] ) throws ChartDataException, PropertyException{
new BarDemo();
}
}
bom oque acontece é q aimgaem gerada quando eu redimenciono a janela ela some, gostaria de saber como deixara imagem fixa, para poder redimensionar a janela sem ela sumir.