Newer
Older
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* StickyFileChooser.java
*
* created: Mon Sep 1 2003
*
* This file is part of Artemis
*
* Copyright (C) 2003 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/StickyFileChooser.java,v 1.1 2004-06-09 09:47:49 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.Options;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
/**
* A JFileChooser that remembers which directory it is in for next time.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: StickyFileChooser.java,v 1.1 2004-06-09 09:47:49 tjc Exp $
**/
public class StickyFileChooser extends JFileChooser
{
/**
* Used to remember the directory the JFileChooser was in when the user
* pressed OK. This is used as the starting directory next time.
**/
private static File last_directory = null;
/**
* Create a new StickyFileChooser and set the current directory to what is
* was after the last call to StickyFileChooser.showOpenDialog() or
* StickyFileChooser.showSaveDialog().
**/
public StickyFileChooser()
{
super();
if (last_directory == null)
{
if (Options.getOptions ().getProperty ("default_directory") != null)
{
final String default_directory =
Options.getOptions().getProperty("default_directory");
setCurrentDirectory (new File (default_directory));
}
else
{
if (last_directory == null)
last_directory = new File (System.getProperty ("user.dir"));
}
}
setCurrentDirectory(last_directory);
setSize(620, 460);
}
/**
* Calls super.showOpenDialog() then remembers the current directory.
**/
public int showOpenDialog(JFrame owner)
{
int status = super.showOpenDialog(owner);
last_directory = getCurrentDirectory ();
return status;
}
/**
* Calls super.showSaveDialog() then remembers the current directory.
**/
public int showSaveDialog(JFrame owner)
{
int status = super.showSaveDialog (owner);
last_directory = getCurrentDirectory ();
return status;
}
}