draggablesplitpanecompose-desktop

What is the Jetpack Compose alternative to JSplitPane?


In Swing I use JSplitPane to create a region with a tree view to the left(leading) and a region with a hex viewer to the right(trailing) where the user can move the divider to adjust the space each get.

Since Jetpack Compose is still relatively new, basic components like SplitView (the hypothetical name for such a component following their naming scheme) don't yet exist. The closest concept I can see is Row and Column but those are not user-resizable (as far as I can tell.)

Without resorting to embedding a Swing JSplitPane and then embedding Compose components in each side of the split pane, is there a good way to do this?

I found one example which got me 90% of the way there, but there was some removed API which is incredibly difficult to find the replacement for as the release notes don't appear to even mention it. (!!)


Solution

  • There is an official implementation for that. You can add this dependency to your build.gradle:

    implementation 'org.jetbrains.compose.components:components-splitpane-desktop:1.0.1'
    

    The newest version can be found here.

    There is also a demo class in the official compose repository that shows how to use it.