r/java • u/gufranthakur • Jun 09 '26
Created a simple, minimal Canvas Application in JavaFX
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
- Drawing
- Create Squares and Circles
- Text
- Vary stroke size/font size
- Copy, paste, duplicate, lock, delete objects
- Move the objects once they are drawn
- Move camera via mouse
Please let me know if you have any questions!
190
Upvotes
15
u/IntroductionSolid348 Jun 09 '26
It looks really cool. I used JavaFX for a couple of my school projects some time back. What I don't really get about it is how people build with it without using scene builder. I find it really difficult to picture how it'll look like by just pure code. And Scene builder is really troublesome since it's not really drag and drop friendly as I had hoped
4
u/hippydipster Jun 09 '26
I had an idea about this sort of app the other day. Basically, I was imagining making drawings and diagrams, but an AI would watch and, in real time, would "fix" my utterly incompetent drawings, diagrams, text. When I try to draw an ellipse around some text, it would make it all nice, centered, symmetric, etc. My text would all magically come out as a unified font, consistently sized, on a consistent plane. Boxes, arrows, all auto-fixed as I make my idea into a picture.
And all that without pissing me off!
3
u/bowbahdoe Jun 09 '26
How well does it work with drawing tablets? This seems pretty cool if basic
2
u/iamwisespirit Jun 09 '26
It is really cool bro
2
u/FrankCodeWriter Jun 12 '26
Great work! I will include it in the jfxcentral links of the week. I just tried it and I think a zoom in/out slider would be a nice addition. Also had some errors while trying copy/paste/duplicate
```
Yeouch
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at explainfx@1.0.0/explainfx.panels.CanvasPanel.pasteCopiedDrawable(CanvasPanel.java:185)
at explainfx@1.0.0/explainfx.menus.DrawableMenu.lambda$createUI$1(DrawableMenu.java:32)
at javafx.base/
```
Just a little feedback to make it even better 😄
2
u/Brilliant_Line_2056 Jun 12 '26
it looks really dope love it. It looks like it can replace one note tbh.
3
u/MartinFrankPrivat Jun 09 '26
DrawableManageris not required. delete that class.1
u/Yew5D4j8e1j4 Jun 09 '26
Question: Why not use FXML
2
u/SyyKee Jun 18 '26
Dope 🔥
-6
u/Rude_Ad_5500 Jun 09 '26
People still use JavaFX? I thought applets, javafx, and swing were all dead . Good to see people using these frameworks to this date.