Tried to remove the top bar

I tried to remove the top bar with chatGpt but sadly i cant get it to work and i cant find anything in the forums!

import processing.javafx.*;
import javax.swing.JFrame;
import processing.core.PApplet;
import processing.javafx.*;
import javafx.embed.swing.JFXPanel;
import javafx.application.Platform;
import javafx.stage.Stage;
import javafx.scene.Scene;

PApplet parent;

void setup() {
  size(400, 300, FX2D);
  parent = this;

  removeTitleBar();
  
  background(220);
  fill(255, 0, 0);
  ellipse(width / 2, height / 2, 100, 100);
}

void removeTitleBar() {
  JFXPanel jfxPanel = (JFXPanel) ((PGraphicsFX2D) g).getNative();
  
  Platform.runLater(() -> {
    Stage stage = (Stage) jfxPanel.getScene().getWindow();
    stage.initStyle(StageStyle.UNDECORATED);
    
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    stage.setX((screenSize.getWidth() - stage.getWidth()) / 2);
    stage.setY((screenSize.getHeight() - stage.getHeight()) / 2);
  });
}

void draw() {
}

You can search this forum for setUndecorated and find many answers.

1 Like

Hi @nuhuhwy,

You can take a look at this thread: