Tips & Tricks

JavaFX Tip 32: Need Icons? Use Ikonli!

Motivation I have been coding JavaFX applications and libraries since 2013 and one thing they all had in common was that I needed to find good icons / graphics that I could use for them. As a former Swing developer I started by using image files, GIFs or PNGs. Normally I would license a library like the "O-Collection" from IconExperience (www.incors.com). But soon it became apparent to me that using image files is too painful. Just imagine for a moment that you want to support different pseudo states of your nodes (e.g. "hover", "pressed", "focused"). You end up with [...]

By |2021-02-18T13:42:23+01:00March 11th, 2020|JavaFX, Tips & Tricks|2 Comments

JavaFX Tip 31: Masking / Clipping / Alpha Channel

Selection Strip I recently had to implement a custom control that lets the user select a single item out of a list of items. This "SelectionStrip" control had to lay out the items horizontally and in case of too many items allow the user to scroll horizontally left and right. The control was to be used in a space-constrained area, so the buttons for scrolling should only appear when needed. They also should not waste any additional space when showing. So I decided to place them on top of the control on the left and right sides. All of [...]

By |2021-02-18T13:42:24+01:00June 29th, 2018|JavaFX, Tips & Tricks|2 Comments

JavaFX Tip 30: ScrollPane with DropShadow

In one of my projects I recently noticed that it was hard for the user to see whether the content of a ScrollPane instance was currently scrolled or not. One way of making this more clear is to add a drop shadow to the top of the scroll pane. This is also something suggested by Google's Material Design. So I gave it a try. In my solution I simply added a region to the ScrollPane and when laying it out I am moving it out of the viewport bounds of the ScrollPane so that only the shadow effect applied [...]

By |2021-02-18T13:42:24+01:00June 19th, 2018|JavaFX, Tips & Tricks|0 Comments

JavaFX Tip 29: Make Layouts Ignore Invisible Nodes

Back in the days when I was still implementing UIs in Swing I used to be a big fan of MigLayout ("one layout manager to rule them all", right Mikael?). One of the features I really liked was the possibility to define different behaviors when a component became invisible. MigLayout allowed me to either preserve the space that the now invisible component occupied or to make it available for the still visible components. So how can I do this in JavaFX? Even though the answer is quite simple it is not obvious by looking at the API. JavaFX uses [...]

By |2021-02-18T13:42:24+01:00June 18th, 2018|JavaFX, Tips & Tricks|0 Comments

JavaFX Tip 28: Pretty List View

When I look at the list views on my mobile phone I always notice that they display their scrollbar (normally a vertical one) very differently than JavaFX does. The same is true for applications running on MacOS X. Below you can see a snapshot of Apple's calendar app. You will notice that the scrollbar is actually on top of the content. In JavaFX the scrollbar would be placed to the right of the view. However on mobile devices in order to save space the scrollbar shows up on top of the content. So obviously I wanted to see how [...]

By |2021-02-18T13:42:24+01:00September 7th, 2017|JavaFX, Tips & Tricks|3 Comments

JavaFX Tip 27: HiRes / Retina Icons

I recently had a lot of icons sent to me by a graphics / UX designer. It was my job to add them to a JavaFX application. Each icon was shipped in three sizes (16x16, 32x32, 64x64). The naming convention for them was like this: icon-name.png icon-name@2x.png icon-name@3x.png At first I thought that this was some kind of standard naming used by graphic designers for their files but in the end it turns out to be a convention that was initially introduced by Apple for their Retina displays and adapted by the JavaFX team. The idea is that JavaFX [...]

By |2021-02-18T13:42:24+01:00August 29th, 2017|JavaFX, Tips & Tricks|1 Comment

JavaFX Tip 26: Go Dark – The “Darcula” Theme

I am a big fan of IntelliJ IDEA and use it every day for the various projects I work on. One thing I like a lot is the dark theme called "Darcula". I like it because it looks cool and because of the low contrast it is better for my eyes. When you stare at something for at least eight hours a day for decades (yes, I am that old) then you better make sure it goes easy on your eyes. This said I obviously also like to use dark themes for my own creations. The following snapshot shows [...]

By |2021-02-18T13:42:24+01:00July 3rd, 2017|JavaFX, Tips & Tricks|0 Comments

JavaFX Tip 25: Use FXSampler!

The Problem As a framework developer it is essential to have an easy way to individually test the appearance of and the interaction with each custom control. I really hate it when I first have to open five different screens before I finally get to my new control so that I can test it. Not only is it annoying but it also costs too much time. When doing UI work you constantly make changes to your controls and look at the impact of those changes. If a single change roundtrip (code, launch, test) takes 5 minutes then you can only squeeze 12 change [...]

By |2021-02-18T13:42:25+01:00March 2nd, 2017|CalendarFX, FlexganttFX, JavaFX, Tips & Tricks|0 Comments

JavaFX Tip 24: Custom Layouts for Performance and Flexibility

I just finished a two month sprint on advancing CalendarFX and getting it ready for release 8.4.0. One focus of this sprint was on performance. There are many things that can influence performance but when it comes to JavaFX the number of nodes in your scenegraph and CSS styling are top candidates for optimisation. After reviewing the custom controls that ship with CalendarFX I realized that many of them used a lot of nested panes (BorderPane, VBox, HBox, GridPane) in order to achieve a specific layout. Nested panes result in a high node count and complex CSS styling instructions. One simple example are [...]

By |2021-02-18T13:42:25+01:00February 1st, 2017|CalendarFX, Java,