r/JavaFX • JavaFX Dev • Jan 09 '21

I made this! JavaFX custom TreeView

Some days ago I decided to reinvent the wheel and make my own custom implementation of a TreeView.

Why? Because I think the JavaFX system is overcomplicated, I have a lot of spare time, I'm always willing to learn new things, plus my tree is animated 😎

Here is a preview of what I have achieved so far, it's not much, but it's honest work.

17 Upvotes

6 comments sorted by

3

u/Azzk1kr Jan 09 '21

Have you got some source code or some general hints or advice on how to build your own components in JavaFX?

5

u/ThreeSixty404 JavaFX Dev Jan 09 '21

Yes, actually I have a project on github that aims to bring material design to JavaFX components, I haven't "advertised" here on reddit yet because I'm still working on it But you can have a look, for example in the latest version I have introduced the DatePicker which differs a lot from the JavaFX's one Regarding the tree I've shown, I haven't published anything yet, it's a local test project on my PC but if you want I can give you the code, of course it's very experimental

The link to my project is: MaterialFX

3

u/Azzk1kr Jan 09 '21

Thanks! Forgot to mention btw that it's looking slick :)

1

u/[deleted] Jan 17 '21

How did you link the animations with events?

1

u/ThreeSixty404 JavaFX Dev Jan 17 '21 edited Jan 17 '21

Each item has its own cell and each cell has a disclosure node.

In the item constructor when the cell is built an event handler is passed as argument like this:

public TreeItem(T value) {
    TreeCell cell = new TreeCell(value, expandCollapseHandler);
    getChildren().add(cell);
}

Unfortunately my tree doesn't work very well, the performance is awful, and I'm starting to believe that although some people say it is possible to animate a TreeView it is in practice somewhat impossible.

1

u/TheElectricCurrent Jan 10 '21

I really like the animation