@Override
  public List<File> getSuggestions(SuggestionQuery query) {
    String value = query.getValue();
    ArrayList<File> list = new ArrayList<>();
    if (value.length() == 0) {
      getFilesRoot(list);
      return list;
    }

    final File f = new File(value);
    final String fileName = f.getName();

    File parentFile = f.isDirectory() ? f : f.getParentFile();
    if (parentFile != null) {
      File[] list1 = parentFile.listFiles((dir, name) -> name.startsWith(fileName) || f.isDirectory());
      if (list1 != null) {
        Collections.addAll(list, list1);
      }
    }
    Collections.sort(list, (o1, o2) -> {
      if (o1.isDirectory() && o2.isDirectory() || !o1.isDirectory() && !o2.isDirectory()) {
        return o1.getName().compareTo(o2.getName());
      } else if (o1.isDirectory()) {
        return -1;
      } else if (o2.isDirectory()) {
        return 1;
      }
      return 0;
    });
    return list;
  }
Created with IntelliJ IDEA.
User: krzyh
Date: 2/28/14
Time: 9:39 PM
To change this template use File | Settings | File Templates.
olv-gui/src/main/java/pl/otros/swing/suggest/demo/StringSuggestionSource.java