I don’t care to turn a Gallery Topic into a discussion that may be distracting from the the work and will provide feedback here instead. I should have done this initially and deleted my posts from there.
The Gallery is for sharing and discussing your work… feel free to use any of this content I am sharing.
// Add to top:
import processing.javafx.*;
import javafx.scene.paint.Color; // The type Color is ambiguous
gc = canvas.getGraphicsContext2D();
// Added these two lines:
gc.setFill(new Color(1, 1, 1, 0.01)); // ensure a visually transparent (or near-transparent) window/area still participates in mouse event handling in Windows
gc.fillRect(0, 0, displayWidth, displayHeight);
gc.setLineWidth(10.0);
Visitors to this topic:
You will have to add the JAR files for JavaFX to the sketch as well to work with Windows.
A search will yield topics on this.
UPDATE
Picking a color with above code changed the color of all the lines that were drawn.
This will update color for each new line that is drawn:
gc = canvas.getGraphicsContext2D();
// Added these two lines:
gc.setFill(new Color(1, 1, 1, 0.01)); // ensure a visually transparent (or near-transparent) window/area still participates in mouse event handling in Windows
gc.fillRect(0, 0, displayWidth, displayHeight);
gc.setLineWidth(10.0);
canvas.setOnMousePressed(event -> {
gc.beginPath(); // Start a new path
gc.moveTo(event.getX(), event.getY());
gc.setStroke(colorPicker.getValue()); // Set color once at start of stroke
});
canvas.setOnMouseDragged(event -> {
gc.lineTo(event.getX(), event.getY());
gc.stroke(); // Draw current segment
});
My lifelong learning journey includes (it is a long list) learning some new programming languages and libraries.
I am learning Java and JavaFX with VSCode outside of the Processing environment but also want to be able to migrate it easily to Processing for future and vice versa.
I adapted the code @svan provided and it will work in both Processing and VSCode Java with some commenting of code.
This is the Processing version with the VSCode parts commented:
Yes, you can do this using py5. Have you seen the py5generator website:py5coding/py5generator · Discussions · GitHub ? There are lots of examples there; you may recognize some of the javafx examples. Below is something I wrote yesterday in Thonny taken straight from a Processing demo that I had previously written with Java code:
This got side tracked and steering it back on course…
Thonny is a Python IDE and not for Java editing.
ChatGPT response:
Is Thonny good as a Java editor?
Is Thonny good as a Java editor?
ChatGPT said:
No, Thonny is not suitable as a Java editor.
Why Not:
Thonny is designed only for Python — it’s great for beginners learning Python, but it has:
No support for Java syntax
No compiler or runtime integration for Java
No Java code completion, error checking, or debugging tools
If you try to open or write Java code in Thonny, it will just treat it as plain text — you won’t get any of the tools you need to write, compile, or run Java code.
Recommended Java Editors (Based on Experience)
Beginner-friendly:
BlueJ – Made for learning Java; visual, simple, and lightweight.
DrJava – Also focused on education; clean and easy to use.
More advanced / professional:
IntelliJ IDEA (Community Edition) – Excellent Java support, smart editor, good for all levels.
Eclipse – Powerful and free; widely used for Java development.
NetBeans – Also strong for Java, especially for GUI-based apps.
:
Use Thonny for Python. For Java, use a Java IDE like IntelliJ, BlueJ, or Eclipse depending on your needs.
Would you like help picking one based on your project type or experience level?