This page was machine-translated from Portuguese and may contain errors. The Portuguese version is canonical.
FilePicker
🔴 · Package:
dev.crossfly.ui.picker· Extends:Picker· Status: reserved (unavailable)
FilePicker is reserved in the 2026 API: in the current code it is just an empty skeleton —
public class FilePicker extends Picker {}
— with no constructors, fields, layout or its own getAnswer(). It inherits getAnswer() from the base (Picker), which returns null; therefore it produces no result and should not be used.
Complete example (copy, paste and run)
FilePicker is reserved and produces no result (it inherits getAnswer() from the base, which returns null). The example below is executable and honestly demonstrates this limitation: it shows the picker, collects getAnswer() and reports that it came back null. To actually pick media, the adjacent button uses the available alternative, PhotoPicker.
package com.exemplo;
import dev.crossfly.ui.*;
import dev.crossfly.ui.layout.*;
import dev.crossfly.ui.picker.*;
/** Runnable main screen. Point the launcher (classname) and run: gradlew :lwjgl3:run */
public class MainWindow extends Window
{
@Override
public void onShow() throws Exception
{
super.onShow();
setLayout(new VerticalLayout());
Label saida = new Label("Resultado: —");
add(LAY_AUTO, saida);
// FilePicker is a reserved skeleton: getAnswer() always returns null.
Button tentarFilePicker = new Button("Tentar FilePicker (reservado)")
.onAction(c ->
{
FilePicker fp = new FilePicker();
fp.show(answer ->
saida.setText("FilePicker devolveu: " + answer + " (reservado, sem resultado)"));
});
add(LAY_AUTO, tentarFilePicker);
// Real alternative to capture media: PhotoPicker.
Button usarPhotoPicker = new Button("Alternativa: PhotoPicker")
.onAction(c ->
{
PhotoPicker pp = new PhotoPicker(PhotoPicker.Preview.PHOTO);
pp.show(answer ->
{
String caminho = (String) answer;
if (pp.isError())
saida.setText("Erro de câmera: " + caminho);
else
saida.setText("Foto salva em: " + caminho);
});
});
add(LAY_AUTO, usarPhotoPicker);
}
}
The snippets below show only the core (what goes inside
onShow()). To run them, place them in theMainWindowskeleton above.
Intended purpose
Browse the file system and return the path of the selected file/folder. The comment in the source indicates the intention to migrate to a lazy tree-based selector from a root — but this has not been ported yet.
What does NOT exist (do not document as available)
The previous implementation (lazy tree with Tree/TreeModel, image preview, volumes via Dropdown, multiple selection) was removed, consistent with the removal of the ui/tree module in the modernization. The old APIs — Filter, initialPath, multipleSelection, mountTree, getTree, etc. — no longer exist.
Alternatives while it is reserved
- To capture media from the camera, use
PhotoPicker. - To pick a color/date/time, use the specific pickers.
- Treat
FilePickeras unavailable until the code is fleshed out.