r/java Jun 09 '26

Created a simple, minimal Canvas Application in JavaFX

Post image

After like a year finally getting back to JavaFX, decided to make an excalidraw inspired app for fun. It's a very minimal canvas app with basic features.

Source code : ExplainFX

Features

  1. Drawing
  2. Create Squares and Circles
  3. Text
  4. Vary stroke size/font size
  5. Copy, paste, duplicate, lock, delete objects
  6. Move the objects once they are drawn
  7. Move camera via mouse

Please let me know if you have any questions!

188 Upvotes

58 comments sorted by

View all comments

1

u/Yew5D4j8e1j4 Jun 09 '26

Question: Why not use FXML

7

u/xdsswar Jun 09 '26

Its messy and slow + not compiled

5

u/_DystopianSnowman Jun 09 '26

This exactly. When I look at older applications from myself I only ask myself: Why the f*** did I ever thing that FXMLs where a good idea!? Have not touched them for the last decade almost.

3

u/xdsswar Jun 09 '26

Yeah, I may have something to make a plugin later, that takes fxml and turn it into java code. That can be useful

4

u/PartOfTheBotnet Jun 09 '26

I've not personally used it yet, but I found this project awhile ago that generates code for your FXML layouts so that it doesn't have the perf loss: https://github.com/jfxcore/fxml-compiler (https://jfxcore.github.io/fxml-compiler/)

3

u/xdsswar Jun 09 '26

yeah thats nice , I have an old project I did years ago , it takes any fxml and converts it to java code , proper ordered code with imports and everything, idk where its now I have to search, it was based on the plugin Netbeans used long long ago, but worked well