https://kotlinlang.org logo
y

Yevhen Tienkaiev

08/30/2022, 9:52 PM
Hello, is there any possibility to show directory selection dialog using JetBrains Compose?
I use this https://github.com/JetBrains/compose-jb/issues/176#issuecomment-1229142697 seems like work(tried on Linux):
Copy code
Button(
                enabled = true,
                onClick = {
                    val fileChooser = JFileChooser().apply {
                        fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
                        dialogTitle = "Select a folder"
                        approveButtonText = "Select"
                        approveButtonToolTipText = "Select current directory"
                    }
                    fileChooser.showOpenDialog(ComposeWindow())
                    homeScreenModel.onUserSelectedDirectory(fileChooser.selectedFile.absolutePath)
                }
            ) {
                Text("Select folder...")
            }
Don't know is it good that UI blocked by
fileChooser.showOpenDialog(ComposeWindow())
in onClick method
d

Dragos Rachieru

08/31/2022, 9:38 PM
I did something similar and answered in another comment, I'll try find the code tomorrow
Check the replies
65 Views