@NotThreadSafe public class FileComboBoxBrowser extends AbstractComboBoxBrowser<String>
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);
Constructor and Description |
---|
FileComboBoxBrowser()
Constructs a new file combo box auto completion browser.
|
FileComboBoxBrowser(FileSystemView fileSystemView) |
FileComboBoxBrowser(JComboBox<String> comboBox) |
FileComboBoxBrowser(JComboBox<String> 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. |
getComboBox, setComboBox
public FileComboBoxBrowser()
AbstractComboBoxBrowser.setComboBox(javax.swing.JComboBox<E>)
must be called in order to use this object.public FileComboBoxBrowser(@CheckForNull FileSystemView fileSystemView)
public FileComboBoxBrowser(@CheckForNull JComboBox<String> comboBox)
public FileComboBoxBrowser(@CheckForNull JComboBox<String> 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 FileSystemView getFileSystemView()
null
before, it's reinitialized
by calling FileSystemView.getFileSystemView()
, 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 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 AbstractComboBoxBrowser<String>
initials
- 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
.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.