JavaFX

JavaFX Tip 5: Be Observable

Even in this time of total NSA surveillance it is still a good idea to implement your JavaFX controls with observability in mind. This is easy to achieve in JavaFX especially compared to Swing. The Old Days Coming from Swing I was used to spending a lot of energy and time on making custom controls observable. It usually required adding methods to add and remove listeners of a certain type. This listener type was a new interface, the single method of that interface accepted a new event object. To send this event object the control had to "fire" it [...]

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

JavaFX Tip 4: Have the Final Word

When developing custom controls for JavaFX I would highly recommend to follow in the footsteps of  the core JavaFX controls and to make the API of your controls as final as possible and to put the "final" keyword in front of all your method declarations. Example In FlexGanttFX I have a lot of code that looks like this: public final Activity getActivityAt(double x, double y) { ... } public final Row getRowAt(double y) { ... } public final void setShowLinks(boolean show) { ... }   Why? When you design a control you have a specific behaviour of the control in [...]

By |2021-02-18T13:42:31+01:00July 9th, 2014|FlexGantt, Java, JavaFX, Tips & Tricks|8 Comments

JavaFX Tip 3: Use Callback Interface

As a UI framework developer it is part of my job to provide ways to customize the appearance and behavior of my controls. In many cases this is done by allowing the framework user to register a factory on a control. In the past I would have created a factory interface for this and provided one or more default implementations within the framework. These things are done differently in JavaFX and I have started to embrace it for my own work. JavaFX uses a generic interface called javafx.util.Callback wherever a piece of code is needed that produces a result (R) for a given parameter [...]

By |2021-02-18T13:42:31+01:00April 15th, 2014|JavaFX, Tips & Tricks|2 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

Finally: Agenda Visualization in FlexGanttFX

Probably a small step for mankind but a giant one for FlexGanttFX. I finished a first working version of actual agenda style visualization of Gantt chart data including editing capabilities. What really made a difference compared to previous attempts in the Swing FlexGantt is the new java.time API. LocalDate and LocalTime came in very handy and make the computation of x and y coordinates a piece of cake. You can see the new agenda layout in the video below. The data in this example is fake, so you will not see any updates to the capacity profiles [...]

By |2021-02-18T13:42:31+01:00March 10th, 2014|FlexGantt, JavaFX|4 Comments

Something to hide? You need HiddenSidesPane

One of my Gantt chart users wanted to use as much real estate on the screen as possible and asked if the scrollbars could be removed. But how do you navigate without scrollbars? Ok, there are all kinds of keyboard shortcuts and of course the usual mouse drag already supported by FlexGanttFX, but a visual control like a scrollbar is something most users would still expect to see these days (at least on desktops). So here is the solution: I used to have a manager who when asked "do you want me to do this or that?" would always [...]

By |2021-02-18T13:42:31+01:00February 24th, 2014|ControlsFX, FlexGantt, Java, JavaFX|4 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