Java

JavaFX Tip 19: Watch Your Skin

A common mistake that I do over and over again is that I put certain code into the skin class of a custom control while it should have been inside the control class itself. I just noticed this again when going through the list of bugs filed for the PopOver control of ControlsFX. I contributed this control, hence I feel responsible for fixing those bugs (when time permits). One of the issues mentioned that it is hard or impossible to change the styling of the PopOver control. After some investigation I realised that I am adding a stylesheet to the [...]

By |2016-07-15T15:38:36+02:00June 5th, 2015|Java, JavaFX, Tips & Tricks|4 Comments

CalendarFX (EA) for JavaFX 8

I am happy to announce the immediate availability of CalendarFX for JavaFX 8 (EA), a framework for creating professional calendar user interfaces for any type of application. The framework provides views for showing calendar entries for a given day, week, month, or year. Several sources (e.g. Google calendar) can be registered with each source consisting of several calendars. Each calendar consisting of hundreds or thousands of entries. CalendarFX can be downloaded here. It ships with several demo applications. Please take them for a spin, try out the API, and let me know what you think. A framework such as this depends [...]

By |2021-02-18T13:42:29+01:00March 18th, 2015|CalendarFX, Java, JavaFX|4 Comments

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=http://youtu.be/cKXFG4pAoys] Update: a new video shows even better how the panes slide in and out. [youtube=http://youtu.be/qdplhq1KJLs] 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 12: Define Icons in CSS

When you are a UI developer coming from Swing like me then there is a good chance that you are still setting images / icons directly in your code. Most likely something like this: import javafx.scene.control.Label; import javafx.scene.image.ImageView; public class MyLabel extends Label { public MyLabel() { setGraphic(new ImageView(MyLabel.class. getResource("image.gif").toExternalForm())); } } In this example the image file is looked up via Class.getResource(), the URL is passed to the constructor of the ImageView node and this node is set as the "graphic" property on the label. This approach works perfectly well but with JavaFX there is a more [...]

By |2021-02-18T13:42:30+01:00July 22nd, 2014|Java, JavaFX, Tips & Tricks|6 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 9: Do Not Mix Swing / JavaFX

The JavaFX team has tried very hard to convince us that migrating from Swing to JavaFX is easy because of the option to embed Swing content in a JavaFX UI and vice versa. I must admit that I never tried it myself but based on the feedback I am getting from my customers I can only recommend to not mix Swing and JavaFX. At the time of this writing there were over 200 unresolved issues (120+ bugs) related to Swing integration (registered with the JavaFX issue management system). Issue Types The following is a list of issues that you might encounter [...]

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

JavaFX Tip 8: Beauty is Skin Deep

If you are developing a UI framework for JavaFX, then please make it a habit to always split your custom controls into a control class and a skin class. Coming from Swing myself this was not obvious to me right away. Swing also uses an MVC concept and delegates the actual component rendering to a UI delegate, but people extending Swing mostly subclassed one of its controls and added extensions / modifications to the subclass. Only very few frameworks actually worked with the UI delegates (e.g. MacWidgets). I have the luxury of being able to compare the implementation of [...]

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

JavaFX Tip 7: Use CSS Color Constants / Derive Colors

When working on FlexCalendarFX I got to the point where I had to define a set of colors to visualize the controls for different calendars in different colors. And not just one color per calendar but several: a background and a text color for deselected / selected / hover states. The  colors were used in several places but for the sake of brevity I only focus on the visual calendar entries in the day view of FlexCalendarFX. The two screenshots below show the same entry, first deselected, then selected. What is important to notice is that these are not completely different [...]

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

JavaFX Tip 6: Use Transparent Colors

Picking the right colors for your user interface elements is always a great challenge, but it is even more challenging when you develop reusable framework controls where you as a developer have no control over the look and feel of the application using them. While you might always add elements on top of the default gray background the developers embedding your controls  might have more of a gothic tendency and use a black background. All of a sudden the nice colors your picked clash with the rest of the application. To tackle this problem the best way I found while working on FlexGanttFX and FlexCalendarFX [...]

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