@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public class FileComboBoxBrowser extends AbstractComboBoxBrowser
AbstractComboBoxBrowser to complete relative and
absolute path names of files and directories.
This class uses a FileSystemView in order to create file objects
for auto completion.
To use it, use something like this:
JComboBox box = new JComboBox();
new FileComboBoxBrowser(box);
box.setEditable(true);
| Modifier and Type | Field and Description |
|---|---|
private File |
directory |
private FileSystemView |
fileSystemView |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
FileComboBoxBrowser()
Constructs a new file combo box auto completion browser.
|
FileComboBoxBrowser(FileSystemView fileSystemView) |
FileComboBoxBrowser(JComboBox comboBox) |
FileComboBoxBrowser(JComboBox comboBox,
FileSystemView fileSystemView)
Creates a new combo box auto completion browser.
|
| Modifier and Type | Method and Description |
|---|---|
File |
getDirectory()
Returns the directory which is used for autocompleting relative path
names.
|
FileSystemView |
getFileSystemView()
Returns the file system view.
|
void |
setDirectory(File directory)
Sets the directory which is used for autocompleting relative path names.
|
void |
setFileSystemView(FileSystemView fileSystemView)
Sets the file system view.
|
protected boolean |
update(String initials)
Interpretes the specified
initials as the initial
characters of an absolute or relative path name of a node in the file
system and updates the contents of the combo box model with possible
completions. |
private boolean |
update0(String initials) |
getComboBox, setComboBoxprivate static final long serialVersionUID
@CheckForNull private transient FileSystemView fileSystemView
@CheckForNull private transient File directory
public FileComboBoxBrowser()
AbstractComboBoxBrowser.setComboBox(javax.swing.JComboBox) must be called in order to use this object.public FileComboBoxBrowser(@CheckForNull
JComboBox comboBox)
public FileComboBoxBrowser(@CheckForNull
FileSystemView fileSystemView)
public FileComboBoxBrowser(@CheckForNull
JComboBox comboBox,
@CheckForNull
FileSystemView fileSystemView)
comboBox - The combo box to enable browsing for auto completions.
May be null.public File getDirectory()
null before, it's reinitialized
by calling
createFileObject(".") on
the current file system view, so null is never returned.public void setDirectory(@CheckForNull
File directory)
directory - The directory to use for autocompletion.
If this is null, the directory is reset to the
current directory.public FileSystemView getFileSystemView()
null before, it's reinitialized
by calling FileSystemView.getFileSystemView(), so null
is never returned.public void setFileSystemView(@CheckForNull
FileSystemView fileSystemView)
fileSystemView - the file system view.protected boolean update(@CheckForNull
String initials)
initials as the initial
characters of an absolute or relative path name of a node in the file
system and updates the contents of the combo box model with possible
completions.
The elements in the combo box model are sorted according to their
natural comparison order.update in class AbstractComboBoxBrowserinitials - The initial characters of a file or directory path name.
May be null.true if and only if the file system contains a
node with initials as its initial characters and
hence the popup window with the completions should be shown.NullPointerException - If the comboBox property is
null.private boolean update0(@CheckForNull
String initials)
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.