Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Component;

import java.io.File;
import javax.swing.JFileChooser;

import javax.swing.filechooser.FileFilter;

public class Main {
    public static File saveImageFile(Component parent) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileFilter(new FileFilter() {
            @Override
            public String getDescription() {
                return "bmp";
            }

            @Override
            public boolean accept(File f) {
                String name = f.getName();
                boolean accepted = f.isDirectory() || name.endsWith(".bmp");
                return accepted;
            }
        });

        fileChooser.showSaveDialog(parent);
        return fileChooser.getSelectedFile();
    }
}