JavaFX Tip 18: Path Clipping

I recently noticed that the PopOver control, which I committed to the ControlsFX project, does not properly clip its content. It became obvious when I was working on the accordion popover for the FlexCalendarFX framework. Whenever the last titled pane was expanded the bottom corners were no longer rounded but square. After placing a red rectangle as content to the titled pane it became clear to me that I forgot to add clipping. The following picture shows the problem. Normally clipping in JavaFX is quite easy. All it takes is an additional node and a call to setClip(node). However, normally [...]

By |2021-02-18T13:42:29+01:00February 18th, 2015|ControlsFX, Java, JavaFX, Tips & Tricks|3 Comments

JavaFX Tip 17: Animated Workbench Layout with AnchorPane

I recently had to implement a layout for an application where the menu area and the status area could be hidden or shown with a slide-in / slide-out animation based on whether the user was logged in or not. The following video shows the the layout in action: [youtube=] Update: a new video shows even better how the panes slide in and out. [youtube=] In the past I probably would have implemented this kind of behavior with a custom control and custom layout code (as in "override layoutChildren() method in skin"). But this time my setup was different because I [...]

By |2021-02-18T13:42:29+01:00February 6th, 2015|Java, JavaFX, Tips & Tricks|4 Comments

JavaFX Tip 10: Custom Composite Controls

Writing custom controls in JavaFX is a simple and straight forward process. A control class is needed for controlling the state of the control (hence the name). A skin class is needed for the apperance of the control. And more often than not a CSS file for customizing the apperance. A common approach for controls is to hide the nodes they are using inside their skin class. The TextField control for example uses two instances of javafx.scene.text.Text. One for the regular text, one for the prompt text. These nodes are not accessible via the TextField API. If you want to get a [...]

By |2021-02-18T13:42:30+01:00July 18th, 2014|ControlsFX, Java, JavaFX, Tips & Tricks|4 Comments

JavaFX Tip 2: Sharp Drawing with Canvas API

When I initially started out working with the Canvas API I noticed that the results of my rendering code were somewhat blurry and even worse, inconsistent. Some lines were blurry, others sharp. Coming from Swing it took me some time to realize that this was caused by the coordinate system of JavaFX, which allows for double precision rendering. To solve this problem all that is needed is to use coordinates "in the middle". So in my code you now find a lot of methods called snapXYZ() (similar methods can be found in the JavaFX code itself), which first casts [...]

By |2021-02-18T13:42:31+01:00April 10th, 2014|Java, JavaFX, Tips & Tricks|5 Comments

JavaFX Tip 1: Resizable Canvas

While working on FlexGanttFX I had to deal a lot with the JavaFX Canvas node. I am using it to render activities on a timeline. Each row in the Gantt chart is a Canvas node. The user has the option to resize each row individually. So I had to figure out the best way to resize a canvas, which out-of-the-box is not resizable. The listing below shows how this can be accomplished. The main steps needed are: Create a subclass of Canvas. Override the isResizable() method and return true. Override the prefWidth() and prefHeight() methods. Return the values of Canvas.getWidth() and Canvas.getHeight(). [...]

By |2021-02-18T13:42:31+01:00April 10th, 2014|Java, JavaFX, Tips & Tricks|18 Comments

And another one: MasterDetailsPane

I finished another JavaFX control today, which I urgently needed for my FlexGanttFX control: a master details pane, which allows the user to show / hide a node with detailed information for a so-called "master" node. My use case is a dual Gantt chart control where a primary (master) Gantt chart is initially shown and then a secondary (details) Gantt chart can be added to the window (stage). By using the MasterDetailsPane the user can easily toggle the visibility of the second Gantt chart at the bottom. At the same time each Gantt chart also has a property sheet [...]

By |2021-02-18T13:42:31+01:00February 4th, 2014|ControlsFX, Java, JavaFX|2 Comments

New JavaFX Control PlusMinusAdjuster

Today I had once again the pleasure to write a small and highly specialized control for JavaFX, which might be useful for others as well. I am calling it PlusMinusAdjuster and all it does is firing value events with values ranging from -1 to +1. The difference to a normal slider is that it continues to fire events even when the value has not changed. This kind of behavior is useful for implementing scrolling through large data sets. A normal scrollbar often causes big jumps even when the user only moves it a few pixels. For me this was [...]

By |2021-02-18T13:42:31+01:00January 28th, 2014|ControlsFX, FlexGantt, JavaFX|3 Comments