private void onSaveAs() {
        ImagemIFrame frame = getSelectedFrame();

        if (frame == null)
            return;

        if (frame.getFile() != null)
            getSaveDialog().setSelectedFile(frame.getFile());

        if (getSaveDialog().showSaveDialog(this) != JFileChooser.APPROVE_OPTION)
            return;

        try {
            String fileName = getSaveDialog().getSelectedFile().getName();
            String format;
            int index = fileName.lastIndexOf(".");
            if (index == -1) {
                fileName = fileName + ".png";
                format = "png";
            } else {
                format = fileName.substring(index + 1);
            }

            File file = new File(getSaveDialog().getSelectedFile()
                    .getParentFile(), fileName);
            ImageIO.write(frame.getImage(), format, file);
            frame.setFile(file);
            setTitle(frame);
        } catch (IOException e) {
            showError("Could not save file!");
        }

    }