Example usage for org.jfree.chart JFreeChart getTitle

List of usage examples for org.jfree.chart JFreeChart getTitle

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getTitle.

Prototype

public TextTitle getTitle() 

Source Link

Document

Returns the main chart title.

Usage

From source file:net.sf.mzmine.chartbasics.chartthemes.EStandardChartTheme.java

@Override
public void apply(JFreeChart chart) {
    // TODO Auto-generated method stub
    super.apply(chart);
    ///*from w  w  w .  j av a  2  s.  co m*/
    chart.getXYPlot().setDomainGridlinesVisible(showXGrid);
    chart.getXYPlot().setRangeGridlinesVisible(showYGrid);
    // all axes
    for (int i = 0; i < chart.getXYPlot().getDomainAxisCount(); i++) {
        NumberAxis a = (NumberAxis) chart.getXYPlot().getDomainAxis(i);
        a.setTickMarkPaint(axisLinePaint);
        a.setAxisLinePaint(axisLinePaint);
        // visible?
        a.setVisible(showXAxis);
    }
    for (int i = 0; i < chart.getXYPlot().getRangeAxisCount(); i++) {
        NumberAxis a = (NumberAxis) chart.getXYPlot().getRangeAxis(i);
        a.setTickMarkPaint(axisLinePaint);
        a.setAxisLinePaint(axisLinePaint);
        // visible?
        a.setVisible(showYAxis);
    }
    // apply bg
    chart.setBackgroundPaint(this.getChartBackgroundPaint());
    chart.getPlot().setBackgroundPaint(this.getPlotBackgroundPaint());

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        // visible?
        chart.getSubtitle(i).setVisible(subtitleVisible);
        //
        if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
            ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(this.getChartBackgroundPaint());
    }
    if (chart.getLegend() != null)
        chart.getLegend().setBackgroundPaint(this.getChartBackgroundPaint());

    //
    chart.setAntiAlias(isAntiAliased());
    chart.getTitle().setVisible(isShowTitle());
    chart.getPlot().setBackgroundAlpha(isNoBackground() ? 0 : 1);
}

From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java

private JFreeChart createEmptyChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart("", // chart
            // title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w ww  . j a v  a  2  s. co m*/

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.getRangeAxis().setRangeWithMargins(0.0, 100.0);
    Font f = chart.getTitle().getFont();
    chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12));
    return chart;

}

From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java

protected void initChart(JFreeChart chart, ChartModel chartModel) {
    if (chartModel.getBackground() instanceof Integer) {
        chart.setBackgroundPaint(new Color(0x00FFFFFF & (Integer) chartModel.getBackground()));
    } else {/*from   ww  w.  j  av a  2 s .c  om*/
        chart.setBackgroundPaint(Color.WHITE);
    }

    if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null)
            && (chartModel.getTitle().getText().trim().length() > 0)) {
        Font font = ChartUtils.getFont(chartModel.getTitle().getFontFamily(),
                chartModel.getTitle().getFontStyle(), chartModel.getTitle().getFontWeight(),
                chartModel.getTitle().getFontSize());
        if (font != null) {
            chart.getTitle().setFont(font);
        }

        RectangleEdge rectangleEdge = RectangleEdge.TOP;
        if (chartModel.getTitle().getLocation() != null) {
            switch (chartModel.getTitle().getLocation()) {
            case RIGHT:
                rectangleEdge = RectangleEdge.BOTTOM;
                break;
            case LEFT:
                rectangleEdge = RectangleEdge.LEFT;
                break;
            case BOTTOM:
                rectangleEdge = RectangleEdge.BOTTOM;
                break;
            }
        }

        chart.getTitle().setPosition(rectangleEdge);
        if (RectangleEdge.isTopOrBottom(rectangleEdge)) {
            HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER;
            if (chartModel.getTitle().getAlignment() != null) {
                switch (chartModel.getTitle().getAlignment()) {
                case LEFT:
                    horizontalAlignment = horizontalAlignment.LEFT;
                    break;
                case RIGHT:
                    horizontalAlignment = horizontalAlignment.RIGHT;
                    break;
                }
            }
            chart.getTitle().setHorizontalAlignment(horizontalAlignment);
        }
    }

    if ((chartModel.getLegend() != null) && chartModel.getLegend().getVisible()) {
        Font font = ChartUtils.getFont(chartModel.getLegend().getFontFamily(),
                chartModel.getLegend().getFontStyle(), chartModel.getLegend().getFontWeight(),
                chartModel.getLegend().getFontSize());
        if (font != null) {
            chart.getLegend().setItemFont(font);
        }
        if (!chartModel.getLegend().getBorderVisible()) {
            chart.getLegend().setFrame(BlockBorder.NONE);
        }
    }

    chart.setBorderVisible(chartModel.getBorderVisible());

    if (chartModel.getBorderColor() instanceof Integer) {
        chart.setBorderPaint(new Color(0x00FFFFFF & (Integer) chartModel.getBorderColor()));
    }

    for (StyledText subtitle : chartModel.getSubtitles()) {
        if ((subtitle.getText()) != null && (subtitle.getText().trim().length() > 0)) {
            TextTitle textTitle = new TextTitle(subtitle.getText());
            Font font = ChartUtils.getFont(subtitle.getFontFamily(), subtitle.getFontStyle(),
                    subtitle.getFontWeight(), subtitle.getFontSize());
            if (font != null) {
                textTitle.setFont(font);
            }
            if (subtitle.getColor() != null) {
                textTitle.setPaint(new Color(0x00FFFFFF & subtitle.getColor()));
            }
            if (subtitle.getBackgroundColor() != null) {
                textTitle.setBackgroundPaint(new Color(0x00FFFFFF & subtitle.getBackgroundColor()));
            }
            chart.addSubtitle(textTitle);
        }
    }
}

From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java

/**
 * Creates a chart.//from   w  ww  .  j  a  va  2 s  .  co  m
 * 
 * @param dataset
 *            dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(CategoryDataset dataset, String title) {

    JFreeChart chart = ChartFactory.createBarChart(title, // chart
            // title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    if (plot.getCategories().size() > 10) {
        plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    }
    Font f = chart.getTitle().getFont();
    chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12));
    return chart;

}

From source file:mil.tatrc.physiology.utilities.csv.plots.RespiratoryPFTPlotter.java

public void formatRPFTPlot(PlotJob job, JFreeChart chart) {
    XYPlot plot = (XYPlot) chart.getPlot();

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }//  ww w.jav  a 2  s .  co  m
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);
}

From source file:com.mxgraph.examples.swing.chart.BarChartDemo1.java

public static JFreeChart createChart1(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("", // chart title
            "X-value", // domain axis label
            "Y-value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w  w  w  . jav a  2 s  .com*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setCategoryMargin(0.1);//
    categoryAxis.setUpperMargin(0.02);
    categoryAxis.setLowerMargin(0.02);

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.10);
    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setItemLabelAnchorOffset(10D);
    renderer.setItemLabelFont(new Font("", Font.PLAIN, 12));
    renderer.setItemLabelsVisible(true);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 180));

    // OPTIONAL CUSTOMISATION COMPLETED.      

    chart.getTitle().setFont(new Font("", Font.BOLD, 16));//

    //
    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    //
    domainAxis.setTickLabelFont(new Font("", Font.PLAIN, 10));

    //
    rangeAxis.setLabelFont(new Font("", Font.BOLD, 15));

    chart.getLegend().setItemFont(new Font("", Font.BOLD, 15));

    /**
     *  chart.getTitle().setFont(new Font("",Font.BOLD,20));//
            
    //
    domainAxis.setLabelFont(new Font("",Font.BOLD,14));
    //
    domainAxis.setTickLabelFont(new Font("",Font.BOLD,12));
    //
    rangeAxis.setLabelFont(new Font("",Font.BOLD,15));
            
    chart.getLegend().setItemFont(new Font("", Font.BOLD, 15));
     */
    return chart;

}

From source file:mil.tatrc.physiology.utilities.csv.plots.ActionEventPlotter.java

public void formatAEPlot(PlotJob job, JFreeChart chart) {
    XYPlot plot = (XYPlot) chart.getPlot();

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }//w w w.jav a 2 s .  c o m
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);
}

From source file:mil.tatrc.physiology.utilities.csv.plots.ConvexHullPlotter.java

protected void formatConvexHullPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1,
        XYSeriesCollection dataSet2) {/*w  w w . j a  v a  2  s . c  o  m*/
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);

    //If there is only one Y axis, color all datasets red (so top, bottom, left, and right will be the same)
    if (job.Y2headers == null || job.Y2headers.isEmpty()) {
        for (int i = 0; i < dataSet1.getSeriesCount(); i++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            renderer1.setSeriesFillPaint(i, Color.red);
            renderer1.setSeriesPaint(i, Color.red);
            if (dataSet1.getSeries(i).getKey() != null
                    && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer1.setSeriesVisibleInLegend(i, false);
        }
    }
    //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing
    else {
        StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
        plot.setRenderer(1, renderer2);

        for (int i = 0; i < dataSet1.getSeriesCount(); i++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            renderer1.setSeriesFillPaint(i, Color.red);
            renderer1.setSeriesPaint(i, Color.red);
            if (dataSet1.getSeries(i).getKey() != null
                    && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer1.setSeriesVisibleInLegend(i, false);
        }
        for (int i = 0; i < dataSet2.getSeriesCount(); i++) {
            renderer2.setSeriesStroke(i, wideLine);
            renderer2.setBaseShapesVisible(false);
            renderer2.setSeriesFillPaint(i, Color.blue);
            renderer2.setSeriesPaint(i, Color.blue);
            if (dataSet2.getSeries(i).getKey() != null
                    && dataSet2.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer2.setSeriesVisibleInLegend(i, false);
        }
        plot.getRangeAxis(0).setLabelPaint(Color.red);
        plot.getRangeAxis(0).setTickLabelPaint(Color.red);
        plot.getRangeAxis(1).setLabelPaint(Color.blue);
        plot.getRangeAxis(1).setTickLabelPaint(Color.blue);
    }
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *//*from  w  w  w.ja v  a  2s  . c  o m*/
protected void configureChart(JFreeChart jfreeChart) throws JRException {
    if (getChart().getModeValue() == ModeEnum.OPAQUE) {
        jfreeChart.setBackgroundPaint(getChart().getBackcolor());
    } else {
        jfreeChart.setBackgroundPaint(null);
    }

    RectangleEdge titleEdge = getEdge(getChart().getTitlePositionValue(), RectangleEdge.TOP);

    if (jfreeChart.getTitle() != null) {
        TextTitle title = jfreeChart.getTitle();
        title.setPaint(getChart().getTitleColor());

        title.setFont(fontUtil.getAwtFont(getFont(getChart().getTitleFont()), getLocale()));
        title.setPosition(titleEdge);
    }

    String subtitleText = evaluateTextExpression(getChart().getSubtitleExpression());
    if (subtitleText != null) {
        TextTitle subtitle = new TextTitle(subtitleText);
        subtitle.setPaint(getChart().getSubtitleColor());

        subtitle.setFont(fontUtil.getAwtFont(getFont(getChart().getSubtitleFont()), getLocale()));
        subtitle.setPosition(titleEdge);

        jfreeChart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreeChart.getLegend();
    if (legend != null) {
        legend.setItemPaint(getChart().getLegendColor());

        if (getChart().getOwnLegendBackgroundColor() == null)// in a way, legend backcolor inheritance from chart is useless
        {
            legend.setBackgroundPaint(null);
        } else {
            legend.setBackgroundPaint(getChart().getLegendBackgroundColor());
        }

        legend.setItemFont(fontUtil.getAwtFont(getFont(getChart().getLegendFont()), getLocale()));
        legend.setPosition(getEdge(getChart().getLegendPositionValue(), RectangleEdge.BOTTOM));
    }

    configurePlot(jfreeChart.getPlot());
}

From source file:semaforo.Semaforo.java

public static void SemaforoGrafico(JFreeChart chart) {

    // set a custom background for the chart
    chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), Color.BLACK, new Point(400, 200), Color.BLACK));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 0));
    PiePlot plot = null;/*from w w w. j a  v  a2 s. c om*/
    plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.00);
    plot.setOutlineVisible(true);

    // use gradients and white borders for the section colours

    plot.setBaseSectionOutlinePaint(Color.BLACK);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(0.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 0));
    plot.setLabelLinkPaint(Color.BLACK);
    plot.setLabelLinkStroke(new BasicStroke(0.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.BLACK);
    plot.setLabelBackgroundPaint(null);
    plot.setLabelBackgroundPaint(Color.BLACK);
    plot.setLabelShadowPaint(Color.BLACK);

    // add a subtitle giving the data source       

    // Mostramos la grafica dentro del jPanel1
    panel = new ChartPanel(chart);
    panel.setBackground(Color.BLACK);
    panel.repaint();

    jPanel3.setLayout(null);
    jPanel3.setLayout(new java.awt.BorderLayout());
    jPanel3.remove(panel);
    jPanel3.add(panel);

    jPanel3.repaint();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    jTabbedPane1.setPreferredSize(new Dimension(screenSize.width, screenSize.height));
}