Scratch for Java

Window::setFullScreen()

Browser availability: desktop-only.

A page may only enter fullscreen right after a click or key press, and learner code runs later; this only reports a limitation. isFullScreen() works and reports the output panel's fullscreen.

Switches between full screen (a borderless window at the screen's size) and a window, e.g. from an options menu. Players can also switch with F11 or Alt+Enter. In a browser, full screen is only allowed right after a click or key press, so it may stay a window there.

Examples

This example requires the desktop runtime in the current browser revision.

void main() {
  Window myWindow = new Window();
  myWindow.setStage(new CustomStage());
}
 
class CustomStage extends Stage {
  public CustomStage() {
    this.display("Press F to switch between full screen and a window.");
  }
 
  @Override
  public void whenKeyPressed(KeyCode keyCode) {
    if (keyCode == KeyCode.F) {
      Window window = Window.getInstance();
      window.setFullScreen(!window.isFullScreen());
    }
  }
}
 

View on GitHub

Syntax

Java

.setFullScreen(fullScreen)

Parameters

Name Data Type Description
fullScreen boolean true for full screen, false for a window

Return

void

setFullScreen()

Create Shareable URL

Select Sections