Style a stage in a minimalist way

There are various modes in which you can style a window in JavaFX. Sometimes it may be interesting to style it in a minimalist way without any window decorations but only the ones provided by the OS such as a drop shadow in Windows 7.

First lets take a look at what JavaFX gives you. There are 4 ways to style your Stage:

  • StageStyle.DECORATED – A stage with solid white background and platform decorations.

  • StageStyle.UNDECORATED – A stage with a solid white background and no decorations.

This is basically just a Stage with no decorations at all just a solid white rectangle with no borders  for you to paint on.

  • StageStyle.TRANSPARENT – A stage with a transparent background and no decorations.

Same as the above but with a transparent background instead of solid white.

  • StageStyle.UTILITY – A stage with a solid white background and minimal platform decorations.

This one is similar to the StageStyle.DECORATED expect that the corners aren’t round, there is no minimize and maximize button and the close button is smaller. Also it does not show up on the windows taskbar so it is not meant to be a top level application window but a secondary one.

So there is no provided way to style a top level window with only the OS decorations. To achieve this you’ll have to create a window with no decorations using StageStyle.UNDECORATED and style the top level container through CSS.

The following code sets the top level container borders as round and adds a drop shadow to achieve the windows 7 appearance:

-fx-background-radius: 6;

-fx-border-color: gray;

-fx-border-style: solid;

-fx-border-width: 1;

-fx-border-radius: 6;

-fx-background-radius: 6;

-fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);

However, there is a problem with this code. The drop shadow will not be visible since it falls outside the bounds of the scene. For it to be visible you’ll have to provide some space around the top level container, you can do this using -fx-background-insets  which sets the insets of the container and -fx-border-insets which sets some space around the borders as well.

So the final CSS for a top level container with a style class of rootPane will look like this:



  -fx-border-insets: 23;

  -fx-background-insets: 23;

  -fx-background-radius: 6;

  -fx-border-radius: 6;

  -fx-border-color: gray;

  -fx-border-style: solid;

  -fx-border-width: 1;

  -fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);


And the window will look like this:

(The logo, top header and close button are later additions, i.e. not a result of the CSS code above)


15 thoughts on “Style a stage in a minimalist way

  1. Java desktop links of the week, September 10 | Jonathan Giles

  2. JavaFX links of the week, September 10 // JavaFX News, Demos and Insight // FX Experience

  3. You minimalistic stage looks really great. I tested your style and resolved the problem that I can’t drag and drop my application any more.
    Do you also have this problem?

  4. Undecorated or Trasparent stage style make some problem in JavaFX 2.2 with minimizing application main Stage to taskbar by mouse click on application button in taskbar. It only can restore from minimized state, but can’t minimize by mouse click.

  5. JavaFX: Stage Style und Decoration | AxxG Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s