---
name: jetbrains-jewel-swing-interop
description: "Embed Jewel Compose UI in Swing."
license: "NOASSERTION"
metadata:
  decimalai-skill-id: "1a224665-b863-41e6-b543-c1ac5b8f88f3"
  decimalai-version-id: "3e4bce17-2b3b-4c3c-bb8b-24cb43823749"
  decimalai-version: "2"
  decimalai-body-sha256: "6035ae4dbf9b616d87d154a06a3e378617285720c82c8d02e600889a73670eda"
  decimalai-name: "jetbrains/jewel-swing-interop"
  decimalai-format: "1"
  decimalai-invocation: "model"
  decimalai-category: "frontend"
  decimalai-source: "https://app.decimal.ai/s/jetbrains-jewel-swing-interop@2/SKILL.md"
---
<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/jewel-swing-interop/SKILL.md -->

# Jewel Swing Interop

Embed Compose/Jewel into Swing with bridge primitives from `ide-laf-bridge` and `foundation`.

## Quick Snippets

Tool window tab:

```kotlin
toolWindow.addComposeTab(tabDisplayName = "My Tab") {
    SwingBridgeTheme {
        MyToolWindowContent()
    }
}
```

Generic Swing host:

```kotlin
val panel = JewelComposePanel {
    MyPluginComposable()
}
```

Manual compositing enablement (non-toolwindow entrypoint):

```kotlin
enableNewSwingCompositing()
val panel = JewelComposePanel { MyPluginComposable() }
```

## Use The Highest-Level API First

Pick the simplest valid entrypoint:

1. Tool window tab: `ToolWindow.addComposeTab(...)`.
2. Generic Swing host: `compose(...)` / `JewelComposePanel(...)`.
3. Custom theming flow: `composeWithoutTheme(...)` / `JewelComposeNoThemePanel(...)`.

Default to themed entrypoints; use no-theme variants only when theme wrapping is intentionally external.

## Enable New Swing Compositing Early

Call `enableNewSwingCompositing()` before attaching Compose content when needed.

Notes:

1. `ToolWindow.addComposeTab(...)` already does this internally.
2. The function is idempotent and safe at multiple entry points.
3. This improves z-order/resizing behavior but can affect performance with infinitely repeating animations.
4. Treat `enableNewSwingCompositing()` and no-theme entrypoints as advanced/experimental paths.

## Apply Bridge Theme In Plugin Context

Use `SwingBridgeTheme` for IntelliJ plugin UI:

1. Pulls Swing LaF colors/metrics/typography into Compose.
2. It provides bridge composition locals for icon and new-UI behavior, clipboard access, density scaling, shortcuts,
   and URI handling.

Do not use standalone `IntUiTheme` for plugin-hosted Swing integration.

## Bridge Compose To Swing/AWT Safely

For bidirectional operations:

1. Use `LocalComponent` to get the host Swing component when APIs require `Component`.
2. Use bridge utilities for color conversion and LaF key lookup when styling custom interop elements.
3. Delegate file chooser and dialog operations to Swing (`JFileChooser`, etc.) from Compose callbacks.

## Version Discipline

Treat this skill as Jewel-version scoped.

1. Ask for target IntelliJ Platform baseline and Jewel API version.
2. Validate behavior against
   [Jewel release notes](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/RELEASE%20NOTES.md)
   when APIs differ by platform generation.
3. Prefer high-level bridge entrypoints that are stable in target versions.
4. For shipped skill updates, refresh reference links to the corresponding release tag.

## Interop Checklist

Before finishing:

1. Confirm compositing flag is set at proper entrypoints.
2. Confirm theme wrapper is `SwingBridgeTheme` (unless deliberately no-theme).
3. Confirm host component access uses `LocalComponent`.
4. Confirm toolwindow integrations use `addComposeTab` when applicable.
5. Confirm interop code avoids creating extra unmanaged `ComposePanel` wrappers.

## References

Read these source files when implementing:

1. [ToolWindowExtensions.kt](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ToolWindowExtensions.kt#L18-L44)
2. [JewelComposePanelWrapper.kt](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanelWrapper.kt#L28-L197)
3. [SwingBridgeTheme.kt](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/SwingBridgeTheme.kt#L36-L72)
4. [Compatibility.kt (`enableNewSwingCompositing`)](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/Compatibility.kt#L5-L17)
5. [README Swing interoperability section](https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/README.md#L458-L473)
