Desktop applications still drive core business workflows across enterprises. Today, many teams ask the same question: “Can we add an AI assistant directly inside our existing desktop software?”

Building a chat UI with modern web frameworks is straightforward, but forcing users to switch out of the main application to an external browser breaks context and reduces adoption.

In this case study, we share how we embedded a DeepSeek V4 web chat assistant inside an existing Java Swing desktop application using Fuzio.


Requirements 

We started with an existing enterprise Swing app featuring a left navigation tree, multi-tab central workspace, forms, and tables—and needed to add an AI assistant without rewriting the app.

Two constraints shaped the design:

  • In-window experience: The assistant must live inside the application window rather than an external browser tab.
  • One-click access anywhere: Users should be able to invoke the assistant from any screen without navigating nested menus.

Architecture 

The solution has three layers: a Vue web chat application, a Swing overlay layer, and an embedded Chromium view connecting the two.

Fuzio Swing AI assistant three-layer architecture

Chat Web Application 

The chat UI is built as a standard Vue web app powered by DeepSeek V4.

Because DeepSeek’s Chat Completions API is OpenAI-compatible, migrating from OpenAI or switching to Qwen, Zhipu, or Ollama later requires changing only the base URL.

Crucially, the chat web app does not need to know it is running inside a desktop app. Frontend engineers can build and test it with standard web tooling without writing Java code.

Swing Overlay 

To avoid disturbing existing business screens, we added the assistant using Swing’s GlassPane—a transparent top-level layer covering the main window. Clicking Ask AI displays a centered overlay hosting the embedded browser:

  • Translucent backdrop dimming the workspace behind it
  • Centered browser container displaying the chat UI
  • Dismissible by clicking outside the card or pressing Esc

Web View Layer 

Fuzio embeds Chromium into Swing via three steps:

  1. Wrap a Chromium Browser instance in a Swing BrowserView inside the GlassPane.
  2. Load the chat web app when the overlay opens.
  3. Configure the JavaScript–Java Bridge so the frontend requests the API key and model configuration from Java at runtime, keeping credentials inside the Java process.

Integrating DeepSeek 

DeepSeek offers fast Chinese-language comprehension and OpenAI-compatible APIs (docs). By pointing the OpenAI JS SDK to https://api.deepseek.com, we can stream completions directly.

Step 1: Expose a Java bridge class. Annotate methods with @JsAccessible so only key management and endpoint config are exposed:

@JsAccessible
public final class AiBridge {

    public String getApiKey()              { /* Return raw key "sk-xxx" or null */ }
    public String chatCompletionsBaseUrl() { /* OpenAI-compatible endpoint base URL */ }
    public String modelName()              { /* Model ID */ }
}

Step 2: Inject the bridge into window. Register an InjectJsCallback:

browser.set(InjectJsCallback.class, params -> {
    JsObject window = params.frame().executeJavaScript("window");
    window.putProperty("fuzioAi", bridge);
    return InjectJsCallback.Response.proceed();
});

Step 3: Stream responses from the frontend.

import OpenAI from "openai";

const bridge = window.fuzioAi;

const client = new OpenAI({
    baseURL: bridge.chatCompletionsBaseUrl(),  // https://api.deepseek.com
    apiKey: bridge.getApiKey(),
    dangerouslyAllowBrowser: true,
});

const stream = await client.chat.completions.create(
    { model: bridge.modelName(), messages, stream: true },
    { signal },
);

Note on dangerouslyAllowBrowser: The OpenAI SDK disables browser execution by default to protect public web apps from leaking keys. Here, the renderer runs inside Fuzio’s local desktop process and the key stays in Java memory.

Streaming Output 

With stream: true, DeepSeek streams Server-Sent Events chunks matching { "choices": [{ "delta": { ... } }] }:

FieldLocationPurpose
delta.roleFirst chunk onlyIdentifies sender as assistant
delta.contentContent chunksIncremental response text (used here)
delta.reasoning_contentThinking modeIncremental reasoning trace
finish_reasonFinal chunkstop or length
usageFinal chunkToken usage breakdown
for await (const chunk of stream) {
    const delta = chunk.choices?.[0]?.delta?.content;
    if (delta) appendToAssistantBubble(delta);
}

Production Considerations 

In production, add error handling, authentication, retry policies, and rate limiting around API calls.

Future Extensions 

DirectionKey Technologies
Enterprise knowledge searchRAG + vector database
Live business data Q&ABridge query methods + Function Calling
AgentsFunction Calling + tool orchestration

Domestic Platform Support 

For deployments in government, finance, energy, and telecom environments requiring Kylin V10, Phytium ARM64, or LoongArch64 compliance, declare the target dependencies in Gradle:

dependencies {
    implementation(fuzio.win64)         // Windows x64
    implementation(fuzio.mac)           // macOS Intel
    implementation(fuzio.macArm)        // macOS Apple Silicon
    implementation(fuzio.linux64)       // Linux x64 (incl. Kylin/openKylin)
    implementation(fuzio.linuxArm)      // Linux ARM64 (Phytium)
    implementation(fuzio.linux64Loong)  // Linux LoongArch64 (Loongson)
    implementation(fuzio.swing)
}

Conclusion 

Three decisions made this integration fast and low-risk:

  • Minimal changes to the Swing app: A single GlassPane overlay left existing business panels untouched.
  • Embedding the UI with Fuzio: Brought a modern Chromium view directly into Swing.
  • Using DeepSeek: Provided strong Chinese comprehension and long-context reasoning over OpenAI-compatible APIs.

The same pattern applies to any web-based module—dashboards, embedded documentation, reports, or data visualizations.

Further Reading 

Add a Chromium-based browser engine to your Java desktop app with Fuzio.

Try for free