which is the correct approach for displaying a jav...
# compose-desktop
p
which is the correct approach for displaying a java UI function, in this case, a
FileDialog
file picker? is not a Composable... but it displays a view on top of my composables:
Copy code
fun openFilePicker(title: String, onFileSelected: (String) -> Unit) {
    val fileDialog = FileDialog(Frame(), title, FileDialog.LOAD)
    fileDialog.isVisible = true
    // Centering dialog
    val screenSize: Dimension = Toolkit.getDefaultToolkit().screenSize
    val centerX = screenSize.width / 2
    val centerY = screenSize.height / 2
    fileDialog.setLocation(centerX, centerY)
    val selectedFilePath = fileDialog.file?.let { "${fileDialog.directory}$it" }
    selectedFilePath?.let {
        extractZipToFolder(it, "gtfs-files")
        onFileSelected(it)
    }
}
At this moment I have it on my class where I have my screen composables, but I'm trying to figure out if I must place it on my viewmodel or where must place it and how to manage it's result. I display it on my Composable when a button is pressed, just adding this on my composable onclick:
Copy code
openFilePicker(
    title = filePickerDialogTitle,
    onFileSelected = {
        vm.updateGTFSFile(it)
    }
)
s
p
thank you for the alternative but that doesn't answers my question
s
This repo contains the answer that you want to know
Create a launcher which is present the file picker action , then call launcher.launch() on the OnClick event
p
well I don't think so, that project is completly different from the java UI i'm using, that remember function doesn't exist for my java ui view
s
I mean you can wrap the create picker behavior into the launcher.launch function,and call the function when you click. This approach is feasible, and Google's permission request is similarly abstract.