public void doSaveAs() throws IOException
    {
        _fileChooser = new JFileChooser();
        ExtensionFileFilter filterPNG = new ExtensionFileFilter("PNG Image Files",
                ".png");
        ExtensionFileFilter filterJPG = new ExtensionFileFilter("JPG Image Files",
                ".jpg");
        _fileChooser.addChoosableFileFilter(filterPNG);
        _fileChooser.addChoosableFileFilter(filterJPG);
        _fileChooser
            .addChoosableFileFilter(new ExtensionFileFilter("All files", ""));

        int option = _fileChooser.showSaveDialog(this);
        if (option == JFileChooser.APPROVE_OPTION)
        {
            String filename = _fileChooser.getSelectedFile().getPath();
            if (isEnforceFileExtensions())
            {
                if (_fileChooser.getFileFilter() == filterPNG)
                {
                    if (!(filename.endsWith(".png")))
                    {
                        filename = filename + ".png";
                    }
                } else if (_fileChooser.getFileFilter() == filterJPG)
                {
                    if (!(filename.endsWith(".jpg")))
                    {
                        filename = filename + ".jpg";
                    }
                }
            }
            if (filename.endsWith(".png"))
            {
                ChartUtilities.saveChartAsPNG(new File(filename), _chart, getWidth(),
                        getHeight());
            } else
            {
                ChartUtilities.saveChartAsJPEG(new File(filename), _chart, getWidth(),
                        getHeight());
            }
        }
    }