Skip to content

Repository files navigation

FastWindow 0.1.1 — Ultra-Fast Win32 Native Window Engine for Java

Status License: MIT Java Platform JitPack

⚡ Ultra-high performance Win32 native window engine specifically designed as the core windowing foundation for FastVulkan, FastGraphics, DirectX and hardware-accelerated composition pipelines.

FastWindow provides zero-overhead, kernel-direct Win32 native window creation (FastWindow.create(...)), bypassing Java AWT/Swing entirely. It guarantees flicker-free resizing, seamless Dark Mode and DWM styling, dynamic Unicode titling, and clean HWND lifecycle management.

FastWindow Showcase


Quick Start

import fastwindow.FastNativeWindow;
import fastwindow.FastWindow;
import fasttheme.FastTheme;

public class NativeExample {
    public static void main(String[] args) {
        try (FastNativeWindow window = FastWindow.create("FastWindow — Native Engine for FastVulkan", 1024, 600)) {
            long hwnd = window.getHWND();
            
            // Dark Mode & Black Titlebar via FastTheme
            FastTheme.setTitleBarDarkMode(hwnd, true);
            FastTheme.setTitleBarColor(hwnd, 20, 20, 20);
            FastTheme.setTitleBarTextColor(hwnd, 240, 240, 240);
            FastTheme.setCornerStyle(hwnd, 2); // Windows 11 Rounded Corners
            
            // Show window seamlessly once styled
            window.setVisible(true);

            while (window.pollEvents()) {
                // Pass hwnd to FastVulkan / GPU presentation loop...
            }
        }
    }
}

Table of Contents


Why FastWindow?

Standard Java windows (JFrame, Frame) on Windows suffer from significant native limitations when used with modern GPU rendering pipelines:

  • Swing/AWT Event Loop Overhead — AWT uses asynchronous, multi-threaded event dispatching that induces boundary jitter and frame drops during live resize.
  • Flicker & Erase Issues — Default Win32 background erases cause white/black flashing before GPU frames present.
  • Lack of Modern DWM Harmony — Java frames cannot natively toggle Windows 11 rounded corners, immersive Dark Mode, or title bar colors without custom JNI hooks.

FastWindow eliminates the entire Java AWT layer and creates pure, kernel-direct Win32 windows with direct HWND access for FastVulkan and FastGraphics.


Key Features

  • 🪟 Pure Standalone Win32 Windows — Zero-overhead native windows with direct UTF-16 Unicode titlebars, fullscreen, centering, and icon support.
  • 🌋 First-Class Vulkan & DirectX Support — Clean HWND handle lifecycle designed for surface creation and zero-jitter live resizing.
  • Zero-Jitter Live Resize — Hardware-synced message pump with immediate bounds dispatching.
  • 📏 Kernel-Level Constraints — Enforces hard Min/Max window sizes directly in the Windows kernel via WM_GETMINMAXINFO.
  • 🎨 DWM & FastTheme Harmony — Native Dark Mode, title bar coloring, and rounded corners for Windows 11.
  • 🔑 Universal HWND Access — Provides a clean 64-bit native HWND handle for Vulkan, DirectX, and DWM composition engines.

Real-World Scenarios

  • 🌋 High-FPS Vulkan Rendering — Dedicated native window surface lifecycle for vkCreateWin32SurfaceKHR without AWT peer synchronization lags.
  • 🎮 Game Engines & Real-Time Simulators — Microsecond message pump with pollEvents() delivering zero-allocation game loops exceeding 1,000+ FPS.
  • 🖥️ Borderless Fullscreen Presenters — Instant transition to exclusive borderless fullscreen for presentations and hardware-accelerated viewport overlays.
  • 🎨 Immersive Windows 11 Desktop Apps — Native dark titlebars, custom background tinting, and rounded corners harmonized with FastTheme.

Performance Benchmarks

FastWindow is rigorously profiled using JMH (Java Microbenchmark Harness) to guarantee zero-overhead event polling and native Win32 dispatching.

Operation / Benchmark Throughput (ops/ms) Ops per Second Latency / Overhead
Message Pump (pollEvents) ~80,159 ops/ms > 80.1 Million ~12 ns
Kernel Constraints (setConstraints) ~57,144 ops/ms > 57.1 Million ~17 ns
Dynamic Unicode Titling (setTitle) ~211 ops/ms > 211,000 ~4.7 µs (DWM Sync)
Bounds Dispatch (setBounds) ~118 ops/ms > 118,000 ~8.4 µs (Win32 API)

Measured on Windows 11, Intel Core i5-1135G7 (Surface Pro 8), JDK 21.0.12.


API Quick Reference

Method Description
static FastNativeWindow create(title, w, h) Creates a standalone native Win32 window (Vulkan/DirectX target).
long getHWND() Returns the 64-bit native window handle (HWND).
boolean pollEvents() Pumps native Win32 message loop (PeekMessageW/DispatchMessageW).
void setTitle(String title) Updates native window title with dynamic UTF-16 Unicode text.
void setVisible(boolean visible) Shows (SW_SHOW) or hides the native window.
void setIconImage(BufferedImage img) Sets the native 32-bit ARGB title bar and taskbar icon.
void setFullscreen(boolean fullscreen) Toggles borderless exclusive fullscreen mode.
void setMinimumSize(minW, minH) Sets kernel-level min track size via WM_GETMINMAXINFO.
void setMaximumSize(maxW, maxH) Sets kernel-level max track size via WM_GETMINMAXINFO.
void setResizable(boolean resizable) Toggles WS_THICKFRAME and WS_MAXIMIZEBOX styles.
void setAlwaysOnTop(boolean alwaysOnTop) Sets HWND_TOPMOST window order.
void centerOnScreen() Centers the window on the active monitor.
void close() Destroys the window handle and frees native context.

Technical Examples & Hero Demos

Case Java Example Launcher Description
Native Black Window & Theme Demo Demo.java run-demo.bat Standalone native Win32 window with Dark Mode, black titlebar, dynamic FPS title, and round icon.
JMH Throughput Benchmark Suite Benchmark.java run-benchmark.bat High-frequency message pump and native call benchmarking.

Installation

Option 1: Maven (Recommended)

Add the JitPack repository and the dependencies to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- FastWindow Library -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastWindow</artifactId>
        <version>0.1.1</version>
    </dependency>

    <!-- FastCore (Required Native Loader) -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastCore</artifactId>
        <version>0.1.0</version>
    </dependency>

    <!-- FastTheme (Optional Styling) -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastTheme</artifactId>
        <version>0.1.4</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastWindow:0.1.1'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
    implementation 'com.github.andrestubbe:FastTheme:0.1.4'
}

Option 3: Direct Download (No Build Tool)

Download the latest JARs directly to add them to your classpath:

  1. 📦 fastwindow-0.1.1.jar (The Core Library)
  2. 📦 fastcore-0.1.0.jar (Required Native JNI loader)
  3. 📦 fasttheme-0.1.4.jar (Recommended for Dark Mode & Styling)

Documentation

  • COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
  • REFERENCE.md: Full API descriptions and method reference.
  • PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
  • ROADMAP.md: Future milestones and planned features.

Platform Support

Platform Status
Windows 10/11 (x64) ✅ Fully Supported
Linux (X11 / Wayland) 🚧 Planned
macOS (Cocoa / Metal) 🚧 Planned

License

MIT License — See LICENSE file for details.


Related Projects

  • FastCore — Native Library Loader for Java
  • FastTheme — Advanced UI Styling Engine (DWM/Mica/Acrylic)
  • FastUI — High-Performance Retained-Mode UI Framework

Part of the FastJava EcosystemMaking the JVM faster. ⚡

About

Ultra-Fast Win32 Native Window Engine for Java, Vulkan, DirectX and DWM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages