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”

JavaFX Fahrenheit to Celsius Converter in FXML

JavaFX Fahrenheit to Celsius Example
JavaFX Fahrenheit to Celsius example using FXML to layout the Scene on the Stage.

JavaFX is easy once you get the hang of it, but for new programmers that requires plenty of examples. More experienced programmers will find one or two examples are enough to master most of JavaFX, so a lot of web sites only put one or two examples up—enough for experienced programmers, but not nearly enough for newer programmers.

In this post, I present the classic temperature converter example modified to use JavaFX. This example uses basic MVC/MVP design. If you want to see this same JavaFX tutorial written in pure Java, look for my other tutorial on this site. It will be the one mentioning pure Java instead of FXML.

Continue reading “JavaFX Fahrenheit to Celsius Converter in FXML”

Restriction on Required Library

JavaFX is part of Java, so why does it prove so difficult to get JavaFX code to compile in Eclipse? You would think there wouldn’t be an issue, but there often is a compile error, “Access Restriction: blah blah is not accessible due to restriction on required library”.

So painful.

There are essentially three fixes for this JavaFX access restriction error in Eclipse. Continue reading “Restriction on Required Library”

What is JavaFX?

JavaFX is a set of software APIs and tools that delivers desktop applications and rich internet applications (RIAs) that can run most anywhere Java runs. JavaFX applications run on Windows, MacOS, iOS, Android, Linux, and many other operating systems. JavaFX replaces Swing and the older AWT as Java SE’s GUI. Oracle is actively improving JavaFX, and likely will for many years to come.

That’s the simple version of what JavaFX is, but not a complete one. After reading the definition of JavaFX, you might still find yourself scratching your head and asking, What is JavaFX?

Obviously, this whole site is dedicated to answering that one question.

Continue reading “What is JavaFX?”

Bare Bones JavaFX “Hello World!”

JavaFX is a Java toolkit for creating visually pleasing apps. Java is a computer programming language that is used to write apps for most any Operating System (OS) that you can think of. That includes Windows, MacOS, iOS, Android, Red Hat, Solaris, AIX, FreeBSD, and many others that exist in the wild. JavaFX handles the windows, buttons, pictures, and graphics for those Java apps.

Never written a JavaFX or even a Java program before? Then, this is a good first app. All it does is create a window that shows the message, “Hello World!”

Continue reading “Bare Bones JavaFX “Hello World!””

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, https://en.wikipedia.org/w/index.php?curid=46225642

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