Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
There have been a few iterations of Java GUI solutions. You will encounter namespace collisions and the predecessors will show up in your search results as you are searching for solutions. Let's go over them so they are familiar
Additional Reading
As you know,
Java's been around for a while.
0:00
And the way to develop rich
GUI applications with Java
0:02
has evolved quite a bit over the years.
0:05
I want to take you on a little
history tour real quick,
0:07
as you will see the predecessors
mentioned and referenced.
0:09
The first thing to remember is
that Java is intended to be,
0:13
write once, run anywhere.
0:16
As you know, different operating systems
have a different way of looking.
0:18
Now, by different,
I mean the native style.
0:22
You know, like,
the window is rounded or sharp.
0:24
The checkbox has depth or it doesn't.
0:27
The scroll bar is around it.
0:29
You know, stuff like that.
0:30
So, in the very beginning there
was a set of tools created called
0:31
the Abstract Window Toolkit, or AWT.
0:36
What AWT provided was a way to expose a
very thin layer that would actually create
0:38
a native window and add a native controls.
0:43
While this was handy, designers didn't
necessarily like how the same half looked
0:46
different on different platforms.
0:50
Now in addition to
the cosmetic differences,
0:52
the way that you interacted with them was
a little bit different on each platform,
0:54
and therefore, some deep knowledge was
needed about all of the platforms.
0:58
Now these differences,
often called quirks,
1:02
is a problem that plagues
web browsers to this day.
1:05
It is not fun.
1:07
So, a couple of groups started projects
to attempt to fix this quirky problem and
1:10
they ended up merging together into one
called the Java Foundation Classes or JFC.
1:15
These were later renamed to Swing and
added to Java, since its release 1.2,
1:21
which was released in late 1998.
1:26
Swing took a different approach.
1:30
It decided to render all of its components
instead of relying on native components,
1:32
like check box and input field.
1:37
This is known as lightweight UI.
1:39
Now, under the covers,
it in fact is still using AWT for
1:40
capturing input like keyboard pressing and
mouse movements.
1:45
But it uses its own interface completely.
1:47
Swing introduced the concept
of a pluggable look and
1:51
feel, also known as skinning.
1:53
What this means was you were
able to change the way that
1:55
all of the components looked at once,
to a completely different look.
1:58
Now Swing had a great run, and it
introduced many advanced component types,
2:02
such as tabs, trees, tables, and lists.
2:06
Swing had widespread acceptance, and
2:09
it was the de facto way to build Java GUI
applications for nearly a decade.
2:11
In late 2008,
a new contender came on the scene, JavaFX.
2:17
Now at first, as expected,
it received mixed reviews.
2:21
The first version introduced a new
scripting language called JavaFX Script.
2:26
No.
2:31
By version two, this was scrapped,
and now, things are just native Java.
2:31
JavaFX has matured, and
releases now follow Java's releases.
2:36
So, JavaFX8 follows JavaSE8,
which was released in 2014.
2:40
And the release for
Java FX9 will follow JavaSE9.
2:46
JavaFX is intended to be the GUI
solution for Java, replacing Swing.
2:52
It and Swing are included in
the Java SE Java Runtime edition.
2:58
Both will be around for
a considerable time though, and
3:02
they interoperate well together.
3:05
For instance, you can have a JavaFX
component embedded in your Swing
3:07
application, and vice versa.
3:10
JavaFX supports Swing components.
3:12
Things that you learned in JavaFX will
more or less, directly translate into
3:15
other UI frameworks that you encounter,
including Swing.
3:19
So with that little Java GUI
history lesson in place,
3:23
let's go spend sometime
getting to know JavaFX.
3:26
You need to sign up for Treehouse in order to download course files.
Sign up