Blame view

JPAINT/jpaint/JPaintFileChooser.java~ 1.08 KB
933d00ad   rlentieu   add JPaint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  import javax.swing.JFileChooser;

  import java.awt.Component;

  import javax.swing.JDialog;

  import javax.swing.JButton;

  

  /**

   * JPaint File Chooser class opens up a file dialog where you can browse

   * for the file you are looking for. You can either choose to save or open the 

   * file aftewards.

   **/

  public class JPaintFileChooser extends JFileChooser

  {

  	private JDialog fileChooserDialog;

  	private ExampleFileFilter filter;

  	

  	/** 

  	 * Creates a default JPaintFileChooser Constructor and sets the extensions

  	 * for files that are only allowed to be opened and saved.  

  	 **/

  	public JPaintFileChooser(Component parent)

  	{

  		// creates a filter and adds the valid extensions on to it

  		filter = new ExampleFileFilter ();

  		filter.addExtension("jpg");

  		filter.addExtension("gif");

  		filter.addExtension("png");

  		filter.addExtension("pdf");

  		setFileFilter(filter);

  		// instantiates the file chooser dialog

  		fileChooserDialog = createDialog(parent);

  	} 

  	

  	/** Returns the file chooser dialog. **/

  	public JDialog getFileChooserDialog()

  	{

  		return fileChooserDialog;

  	}

  }