JavaFX Drag and Drop Images

If you deal with files in your JavaFX app, then you need to have drag and drop integration. You’ll be amazed at how easy drag-and-drop is in JavaFX.

The following JavaFX image drag-and-drop example only takes three files. You can just copy them into your JavaFX project, and run them if you’d like.

The resulting application allows you to drag an image file onto your window. As the image file moves over the window, it will change in a OS specific way, indicating that you can drop the file onto the open window. Once you drop the image file on to the window, the image will be displayed in the window. Continue reading “JavaFX Drag and Drop Images”

Drawing Squares and Circles in JavaFX

JavaFX Shapes
Drawing shapes in JavaFX is easy.

JavaFX is all about graphics and drawing. Sure JavaFX can do great layouts, but if you need to visualize results, add images to layouts, or display data, JavaFX has all the tools you’ll need. Even games are written using JavaFX.

If you don’t know where to start learning JavaFX graphics capabilities, start with this tutorial. This tutorial explains how to draw JavaFX circles and squares after laying out your JavaFX UI using Scene Builder. It may not be glamorous, but it is a beginning. Continue reading “Drawing Squares and Circles in JavaFX”

Drawing Squares and Circles in JavaFX in Pure Java

I already gave an example of how to draw Squares and Circles on an FXML-generatated UI. Sometimes, you want to work without taking the time to create an FXML document. So this example delves into doing the same thing without using FXML.

Just drawing squares isn’t extremely exciting, because, … let’s face it, … the only time you want a window with one square and one circle in it, is when you are implementing the Candy Land board game.

Classic Candy Land Board Game
The only time you need just a circle and a square in a window, is when you are implementing a Candy Land game.
By Source (WP:NFCC#4), Fair use,

Continue reading “Drawing Squares and Circles in JavaFX in Pure Java”