I agree that different people would like different things....
here is mine ;)

This styling is widely used in scripting languages, jQuery is a good example. Its done by always return an object from an operation, in this example setColor() will return the same object that was returned from hover(), allowing further manipulation in the same line of code. For example button.border().hover().setColor(red).setStrokeWidth(10).setBlink(false).setHandler(()->{}); If readability is an issue it can be formatted as:


And this reminds me another issue, which may be a fork, but in my point of view its originated from the same approach, which is users manipulate internal data structures directly to do operations. I didn't understand the design decision to expose internal structures in FX to do operations and manipulate them directly. In this case properties, another example is root.getChilderen().add(). This not only expose the internal data structure, but also requires more coding for simple trivial operation. users >90% don't need/care about the internal data structures, but 100% want to write less and simpler code. Usually user just want to do some trivial thing, add, remove, traverse..., for those common cases an alias can be used that encapsulate inside it the data structure used and the language quirks. In this example root.add() would do the trick. Other operations could look similar, like root.clear(), root, remove(...). root.traverse()(will return an iterator). For those edge cases which requires manipulating the data structure directly API can expose them, like root.getChildrensAsList(), or root.getChildren()

Combining the 2 approaches and the ability to retrieve the nodes related to the operations in 2 levels, say through .base() and .parent(), would yield the results that Oliver suggested (as I understood them)

(hope the layout wouldn't get scrambled upon send)

Group root = new Group()
                            .add( new Button()

.parent() //parent() return border

.base().caption() //base() return button

                                    new Button("button 2").caption()
                        )//end of add()

my 0.002$

On 12/17/2013 11:18 PM, David Grieve wrote:
It is possible, but probably not in the way that 
https://javafx-jira.kenai.com/browse/RT-17293 would provide. By that I mean, it would be 
nice to be able to progammatically say "the border color for this button when 
hovered is red." This can be done now by adding an invalidation listener to the 
hoverProperty and setting the border on Region, but I don' t think this is what you are 

I think RT-17923 means different things to different people. I'd be interested 
to know what such and API would look like to you.

On Dec 17, 2013, at 3:39 PM, Oliver Doepner <odoep...@gmail.com> wrote:


This might have been asked before but I haven't found it:
Is it possible to style JavaFX components using pure Java (i.e. without

If this is being worked on, does anyone know what the status is?

I think this is one of the areas where JavaFX can actually be better than
HTML5/CSS because a nicely typed Java representation of CSS could provide
great tooling and features that others had to invent LESS or SASS for.

I have seen this (from Oct 2012):

I have also seen this: https://javafx-jira.kenai.com/browse/RT-17293
Last update: Brian
a comment - Mar,
12 2012 09:01 PM : "It is now past the point where this feature can be
added for 2.1. Will need to be considered for a future release"


Oliver Doepner

Reply via email to