# How to make a program windowless/frameless?

**URL:** <https://discourse.processing.org/t/how-to-make-a-program-windowless-frameless/22321>\
**Category:** Coding Questions\
**Created:** [July 2, 2020, 9:19am UTC](https://discourse.processing.org/t/how-to-make-a-program-windowless-frameless/22321 "2020-07-02T09:19:19Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 25, 2026, 2:32am UTC](https://discourse.processing.org/t/how-to-make-a-program-windowless-frameless/22321/13 "2026-01-25T02:32:35Z")

</div>

Hello folks!

This will work on W10 and Processing 4.4.10 in a Swing window:

```processing
/*
  Processing + Swing Overlay Demo
  -------------------------------
  Goal:
    Render content offscreen in Processing (PGraphics), convert it to a Java BufferedImage,
    then display it in a transparent, undecorated, always-on-top Swing JFrame.

  Pipeline:
    PGraphics (JAVA2D) -> PImage snapshot -> BufferedImage (ARGB) -> ImageIcon/JLabel -> JFrame

  Key points:
    - Processing launches the app and renders offscreen only.
    - Swing owns the visible window (JFrame) and presents the BufferedImage.
    - Alpha transparency is preserved end-to-end (clear() + TYPE_INT_ARGB + transparent JFrame).
*/

import java.awt.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
//import java.net.*;
//import java.io.*;

// ==============================
// Global Variables
// ==============================

JFrame frame; // Floating Swing window
BufferedImage img; // Final Java image buffer for Swing

// Offscreen drawing surface (Processing)
PGraphics pg;

// ==============================
// Processing Setup
// ==============================

void settings() {
  size(1, 1); // Minimal Processing window
}

void setup() {
  surface.setVisible(false); // Hide the Processing window
  createImageWindow(); // Build and show the Swing overlay
}

void draw() {
  // No Processing drawing on the main surface; Swing handles the visible window.
}

// ==============================
// Build the Swing overlay window
// ==============================

void createImageWindow() {

  // 1) Render offscreen to a PGraphics buffer.
  // JAVA2D keeps pixels CPU-accessible for transfer into BufferedImage.
  pg = createGraphics(200, 100, JAVA2D);
  pg.beginDraw();
  pg.clear(); // Transparent background
  pg.fill(0, 255, 0);
  pg.textSize(48);
  pg.textAlign(CENTER, CENTER);
  pg.text("TEXT", pg.width/2, pg.height/2);
  //pg.save("/data/image.png"); // Optional: save the generated buffer
  pg.endDraw();

  // 2) Snapshot the PGraphics into a PImage (CPU-side pixel array).
  PImage pi = pg.get();

  // Optional: use a file image instead of generated content.
  //pi = loadImage("image.png");

  pi.loadPixels();

  // 3) Copy Processing pixels (ARGB ints) into a Java BufferedImage (ARGB).
  BufferedImage img = new BufferedImage(pi.width, pi.height, BufferedImage.TYPE_INT_ARGB);
  img.setRGB(0, 0, pi.width, pi.height, pi.pixels, 0, pi.width);

  // 4) Display in Swing: ImageIcon -> JLabel -> transparent, undecorated JFrame.
  ImageIcon icon = new ImageIcon(img);
  JLabel label = new JLabel(icon);

  frame = new JFrame();
  frame.setUndecorated(true);
  frame.setBackground(new Color(0, 0, 0, 0)); // Transparent window background
  frame.setAlwaysOnTop(true);
  frame.add(label);
  frame.pack();
  frame.setVisible(true);
}

```

Reference:

> [@Making a program without a window border (and no background, just the shape)](https://discourse.processing.org/t/making-a-program-without-a-window-border-and-no-background-just-the-shape/41260):
>
> ok, I was wondering if there a way to make a program using processing let say I’m making a stick figure, but I want the figure to appear on my screen instead of in the display box. what usually happens what i want to happen yes i messed up with the pics but you should get the idea

`:)`

---

_[View the full topic](https://discourse.processing.org/t/how-to-make-a-program-windowless-frameless/22321)._
