Tips & Tricks

­
19 08, 2014

JavaFX Tip 14: StackPane Children – Hidden But Not Gone

By |August 19th, 2014|JavaFX, Tips & Tricks|5 Comments

Another short tip: Swing provides a layout manager called CardLayout, which manages a set of components (cards) inside a container but always only shows one of them. The method CardLayout.show(Container, String) allows to switch between the components / the cards. The same behaviour can be accomplished in JavaFX by using the StackPane, adding several children [...]

19 08, 2014

JavaFX Tip 13: Study Modena CSS File

By |August 19th, 2014|JavaFX, Tips & Tricks|3 Comments

This is the easiest and shortest tip so far. If you want to do any of the following things: learn how to use CSS make your custom controls look like the standard controls reuse an SVG path graphic used by a standard control (e.g. scrollbar arrows) figure out how to navigate the structure of the standard [...]

22 07, 2014

JavaFX Tip 12: Define Icons in CSS

By |July 22nd, 2014|Java, JavaFX, Tips & Tricks|6 Comments

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 [...]

18 07, 2014

JavaFX Tip 11: Updating Read-Only Properties

By |July 18th, 2014|JavaFX, Tips & Tricks|0 Comments

Custom controls often feature "read-only" properties. This means that they can not be set from outside the control, not even from their own skin class. It is often the behaviour of a control that leads to a change of the read-only property. In JavaFX this behaviour can be implemented in the control itself and in the [...]

18 07, 2014

JavaFX Tip 10: Custom Composite Controls

By |July 18th, 2014|ControlsFX, Java, JavaFX, Tips & Tricks|4 Comments

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 [...]

17 07, 2014

JavaFX Tip 9: Do Not Mix Swing / JavaFX

By |July 17th, 2014|Java, JavaFX, Tips & Tricks|4 Comments

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 [...]

14 07, 2014

JavaFX Tip 8: Beauty is Skin Deep

By |July 14th, 2014|FlexGantt, Java, JavaFX, Tips & Tricks|2 Comments

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 [...]

11 07, 2014

JavaFX Tip 7: Use CSS Color Constants / Derive Colors

By |July 11th, 2014|FlexGantt, Java, JavaFX, Tips & Tricks|4 Comments

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 [...]

11 07, 2014

JavaFX Tip 6: Use Transparent Colors

By |July 11th, 2014|FlexGantt, Java, JavaFX, Tips & Tricks|2 Comments

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 [...]

10 07, 2014

JavaFX Tip 5: Be Observable

By |July 10th, 2014|FlexGantt, Java, JavaFX, Tips & Tricks|3 Comments

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 [...]