# How do I create a fullscreen window with title bar on my second monitor?

**URL:** <https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474>\
**Category:** Coding Questions\
**Created:** [March 27, 2023, 1:23pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474 "2023-03-27T13:23:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![esc746](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/esc746/32/4258_2.png) [@esc746](https://discourse.processing.org/u/esc746)\
**Post date:** [March 27, 2023, 1:23pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/1 "2023-03-27T13:23:12Z")

</div>

The title describes the problem.

I can use fullScreen() to cover the screen with a window on any monitor. But it doesn’t have a title bar.

The following code creates a window with a title bar that covers the screen. But only for the default monitor. (Also, the positioning is wrong, since a bug persists from years ago.)

```auto
void settings() {
    size(displayWidth, displayHeight);
}

void setup() {
    surface.setTitle("my application");
    surface.setLocation(0, 0);
}

void draw() {
    background(0);
    fill(200);
    circle(mouseX, mouseY, width/4.);
}

```

---

<div class="post-metadata">

**Author:** ![esc746](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/esc746/32/4258_2.png) [@esc746](https://discourse.processing.org/u/esc746)\
**Post date:** [April 12, 2026, 6:59pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/2 "2026-04-12T18:59:20Z")

</div>

Three years later and I found my own post about the problem. Which still exists!

How do we properly position a window without an error of several pixels?

How can we create a window on a second monitor that is NOT full screen?

---

<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:** [April 13, 2026, 3:28am UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/3 "2026-04-13T03:28:19Z")

</div>

Hello @esc746,

I have used _java.awt.Robot_ for issues like this and it works for Windows 10 and has been useful for other projects for me.  
There may be other solutions.

This seems to work for Windows 10:

```processing
import java.awt.Robot;
import java.awt.event.KeyEvent;

void settings() {
    size(displayWidth, displayHeight);
    println(displayWidth, displayHeight);
}

void setup() {
    // Initialize surface size to full screen
    surface.setResizable(true);
    //surface.setLocation(0, 0);
    //surface.setSize(displayWidth, displayHeight);

    // Maximize window using Robot (Windows-specific)
    try {
        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_SPACE); // Open the window menu
        robot.keyRelease(KeyEvent.VK_SPACE);
        robot.keyRelease(KeyEvent.VK_ALT);

        //delay(100); // Add a small delay for the menu to open

        robot.keyPress(KeyEvent.VK_X); // Simulate pressing "X" to maximize the window
        robot.keyRelease(KeyEvent.VK_X);
    } catch (Exception e) {
        println("Error using Robot to maximize window: " + e);
    }
}

void draw() {
    background(0);
    fill(200);
    circle(mouseX, mouseY, width / 4.0);
}

```

This is my monitor arrangement (they are each 1920x1200):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/3/73c634252a336c895f6a00e69a1769b863f6717d.png)

This moves it to my second monitor:

`surface.setLocation(-displayWidth, 0);`

Reference:

> **[Robot (Java SE 17 & JDK 17)](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/Robot.html)**
>
> declaration: module: java.desktop, package: java.awt, class: Robot

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [April 13, 2026, 3:40am UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/4 "2026-04-13T03:40:19Z")

</div>

The operating system was not given in your post. The following source code works on a Mac M4 running Tahoe 26.2:

```processing
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

void setup() {
  size(600,600);
  surface.setTitle("Default Window");
  surface.setResizable(true);
  JFrame frame = new JFrame("JFrame Window");
  frame.setBounds(2500,200,800,800);
  frame.setVisible(true);
  frame.setAlwaysOnTop(true);
}

void draw(){
}

```

---

<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:** [April 13, 2026, 3:48am UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/5 "2026-04-13T03:48:03Z")

</div>

> [@svan](#):
>
> The following source code works on a Mac M4 running Tahoe 26.2

Output from your code on Windows 10 has a similar issue with the original sketch (it is off to the right a few pixels):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/0/408b33f1f21942b24980d316fb86fcdcd35b3931.png)

Only adjustment to your code:

```auto
  frame.setBounds(0, 0, 1920, 1200); // Display 1
  //frame.setBounds(-1920, 0, 1920, 1200); // Display 2

```

_Update_

My monitors are 1920x1200 so the above is same as:

```auto
  frame.setBounds(0, 0, displayWidth, displayHeight); // Display 1
  //frame.setBounds(-displayWidth, 0, displayWidth, displayHeight); // Display 2

```

See previous posts for my monitor arrangement which is why there is a `-displayWidth`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [April 13, 2026, 3:55am UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/6 "2026-04-13T03:55:52Z")

</div>

Not sure what you’re trying to say. JFrame is on second monitor and he stated that he did not want it full screen, although that can be easily done by hitting the third button on a Mac.

---

<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:** [April 13, 2026, 5:07pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/7 "2026-04-13T17:07:57Z")

</div>

Hello folks!

Summary of my observations follows…

Observation #1:

- Windows 10
- Orange background.
- Code from original post.
- `surface.setLocation(0, 0);`

Upper left corner:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/7/f724cb0c13b0758414c566af149537e852fcb327.png)

It goes off the screen on the right side.

Observation #2:

- Same as #1 with this change to move to second monitor:
- `surface.setLocation(-displayWidth, 0);`
- The same offset as #1 is observed

Observation #3:

- Windows 10
- Code from @svan post
- `frame.setBounds(0, 0, 1920, 1200); // Display #1 resolution`

Upper left:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/c/2ca5572684076ba65acdb60b56b8566fc658edab.png)

Bottom left:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/0/e03b8eb01b15f42e2494ad6aeffdc6305a8e2c02.png)

Upper right:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/b/1b16b7a0f8ac314c1d8238812fc4c2c1285b1cb0.png)

Observation #4:

- Windows 10
- Code from @svan post
- `frame.setBounds(-1920, 0, -1920, 1200); // Display #2 resolution`

This moves it to the second display with the same results as #3

Observation #4:

- Windows 10
- Code from original post.
- This is _ **required** _ to maximize it (keyboard, mouse or  
java.awt.Robot) with Windows:  
`surface.setResizable(true);`

Before (it is off screen to the right):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/a/2a850abb2c9d4fc6c16c1173acd4bf0c64d12cf7.png)

Maximized (title bar is smaller vertically and also fits inside Windows display):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/8/98b9be206315e963691a1cea1c35bb8ce2cc5d4f.png)

The above may provide some insight to the behavior on Windows and a solution\workaround for your questions (subject and posts).

I did try and in the end the Windows keyboard\mouse or automating with _java.awt.robot_ was a solution on my end to maximize it with the title bar.

As for the placement being off I do not have an answer for this at this time.

Have fun!

And finally… It only works for the default JAVA2D renderer:

> **Code**
>
> Chat GPT (free version) was used to help iterate down to a working minimal solution after _many failed attempts_.
> 
> Windows 10 PC.
> 
> ```processing
> import javax.swing.JFrame;
> import processing.awt.PSurfaceAWT;
> 
> JFrame frame;
> 
> void setup() {
> size(600, 400); // Default is JAVA2D
> surface.setTitle("Processing Window Control Demo");
> surface.setResizable(true);
> surface.setLocation(100, 100); // Display 1
> //surface.setLocation(-1920 +100, 100); // Display 2
> 
> // Correct way to get the JFrame in Processing 4
> PSurfaceAWT awtSurface = (PSurfaceAWT) surface;
> PSurfaceAWT.SmoothCanvas canvas = (PSurfaceAWT.SmoothCanvas) awtSurface.getNative();
> frame = (JFrame) canvas.getFrame();
>   
> // Cool trick! 
> // Simulates keypress on start to maximize:
> //key= 'X';
> //keyPressed();
>   
> //Or do this:
> //frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
> }
> 
> int count = 0;
> 
> void draw() {
> background(200);
>    
> fill(0);
> textSize(24);
>   
> if (frameCount%30 == 0)
> count++; 
>    
> textAlign(LEFT, TOP); 
> text(count, 10, 10); 
>   
> textAlign(CENTER, CENTER);
> text("Window Controls:\n" +
> "M = Minimize\n" +
> "X = Maximize\n" +
> "R = Restore\n" +
> "H = Hide\n" +
> "S = Show", width/2, height/2);       
> }
> 
> void keyPressed() {
> if (key == 'M' || key == 'm') {
> frame.setState(JFrame.ICONIFIED); // Minimize
> } else if (key == 'X' || key == 'x') {
> frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // Maximize
> } else if (key == 'R' || key == 'r') {
> frame.setExtendedState(JFrame.NORMAL); // Restore
> } else if (key == 'H' || key == 'h') {
> frame.setVisible(false); // Hide
> } else if (key == 'S' || key == 's') {
> frame.setVisible(true); // Show
> }
> }
> 
> ```

Reference:

> **[JFrame (Java SE 17 & JDK 17)](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/JFrame.html)**
>
> declaration: module: java.desktop, package: javax.swing, class: JFrame

I restored my orange background to a nice comfortable black.

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [April 13, 2026, 8:57pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/9 "2026-04-13T20:57:10Z")

</div>

`(Also, the positioning is wrong, since a bug persists from years ago.)`

There is nothing wrong with the original post on my Mac system so it must be a Windows problem.

The image below is a screenshot from my Mac:

 ![scrnShot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/b/cb605e4eaa83a202aa4adfc90b268e197c4bd476.jpeg)

---

<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:** [April 14, 2026, 7:26pm UTC](https://discourse.processing.org/t/how-do-i-create-a-fullscreen-window-with-title-bar-on-my-second-monitor/41474/10 "2026-04-14T19:26:46Z")

</div>

Hello @esc746,

I did some further exploration here:

> [@Native window access and inset handling in Processing JAVA2D and P2D](https://discourse.processing.org/t/native-window-access-and-inset-handling-in-processing-java2d-and-p2d/48437):
>
> Hello folks! This is an exploration of native window access in P2D/P3D and JAVA2D. In my Windows 10 environment, I was seeing offsets, and I was compelled to understand why. And now I do! play_button P2D Codeplay_button JAVA2D Code That was fun! slight_smile

It certainly helped me understand the behavior in Windows 10 and make adjusments as required.

`:)`
