Wednesday, February 20, 2013

Custom JavaFX Windows


I've been learning JavaFX and decided to make a Pane wrapper to create custom windows for JavaFX applications.  By default your choices are to use the standard OS window, a minimalist OS window, or an undecorated window (no window encapsulation at all).  I like having full control over the window behavior and appearance so I've set up a StackedPane which will surround your content pane (Client Area in the image above) with a CSS customizable pane with the usual window features.  Shown below is a quick little example with some very simple styling.


The resize and movement behavior is achieved using regions that have been set up in the scene builder as shown to the right.

Below is a video of some of the behavior in action as well as a look at the controller for the window functions.  There have been a few changes since I made that video.  The biggest change is that I switched from extending Stage to extending StackPane, this change makes life a lot easier down the road when trying to deal with inheritance.

I still need to add window snapping and the ability to restyle the window on maximize (e.g. get rid of rounded corners).






3 comments:

  1. I think I'm going to hold onto the source for now. It isn't quality enough for distribution yet. I just finished my first project with it and discovered some issues that should fixed.

    InSideFX has a similar project, though it is quite a different look, is much more complicated, and is buggy on multi-monitor setups. You can find it here:
    Undecorator

    ReplyDelete
  2. Hows your state? I really look into the sourcecode.

    ReplyDelete