Meet JavaFX3:58 with Craig Dennis
JavaFX is a modern framework for building desktop and rich Internet applications. JavaFX is written in pure Java and supports rich animations, 3-D rendering, as well as rich media, and many more bells and whistles that you would expect in a present day desktop application.
- Stage - Using the theatre analogy, this is where your application is presented
- Scene - A stage can have one or more scenes that are switched out
- Scene Graph - These are the items that will make up the scene, in the theatre analogy this could be assumed to be the set, you know, the walls, the furniture and other set pieces.
- Nodes - Everything that is added to the scene graph is a Node. Every node (except the root) has one single parent, and there can be multiple children.
- Root Node - The first node in the graph that has many children.
Allow me to introduce you to JavaFX. 0:00 JavaFX is a modern framework for building desktop and rich Internet applications. 0:03 JavaFX comes from an initial acquisition of a company that had produced 0:09 an environment named F3. 0:13 F3 stood for form follows function. 0:15 And it set out to make GUI programming easier in general. 0:18 If you have experience with web development, 0:22 this environment will be comfortably familiar. 0:25 If you do not have web coding experience yet, 0:28 you're going to get a nice head start into the web world. 0:30 JavaFX is written in pure Java and it supports rich animations, 0:32 3D rendering as well as rich media. 0:37 And many more bells and 0:41 whistles that you would expect in a present day desktop application. 0:42 It's multithreaded,meaning many different processes can happen all at once behind 0:46 the scenes. 0:50 And it's now the de facto way to begin building a GUI application in Java. 0:51 While it interoperate's with Swing, the plan is that it will be it's replacement. 0:56 JavaFX introduced the concept of native deploys, 1:02 which means your users will be able to install your application just like 1:05 they would any application they choose to install on their own operating system. 1:08 You just build the package and the correct Java runtime edition and 1:12 starting points will be installed on your client's machine. 1:15 And they could run things with a double-click. 1:18 So now, you know a bit about what JavaFX is, 1:21 let's focus on how you're gonna use it. 1:24 One of the hardest things to do in programming, is to name something. 1:27 You'll be surprised at how much time of your career, is spent thinking of a word, 1:30 trying to explain the concept of what you're doing, just so 1:35 the next person reading your code can understand it. 1:38 Now, one of the reasons that this is hard is because words in English 1:40 are often overloaded, and they mean multiple things. 1:44 As you can imagine, naming parts of an entire framework is very hard. 1:47 JavaFX employs a design analogy that helps you understand how things are working. 1:54 JavaFX likens itself to a theater, and putting on a play. 1:59 So, the place where you view things as an audience member, 2:03 it's called a stage, right? 2:06 And the part of the play being performed on that stage is called a scene. 2:08 So much like any presentation, there can be multiple scenes put on the same stage. 2:13 For instance, if the play was Romeo and Juliet, 2:18 one scene on the stage could be Juliet's chamber room. 2:21 And then when it's time for the scene to be over, the lights go down, and 2:24 the scene is switched out to another scene, the grand ballroom. 2:27 The set pieces on the stage are lined up to convey the scene, hopefully. 2:31 Now when you see those words, you won't be confused and 2:36 you'll understand how they intended you to use the framework. 2:38 Now before embracing that analogy, 2:41 you might have been confused by their overloaded versions. 2:43 Here, listen to these sentences. 2:46 When my daughter doesn't want to leave a playground, she sure makes a scene! 2:48 I really hope it's just a stage. 2:52 See, they're the same words, but it's totally different meaning. 2:54 All right, so since we have our theater analogy in place, 2:57 let's take a look at what we can do to set up our scene. 3:00 Now, unfortunately, the things that you build on a scene aren't called sets, 3:04 like they are called in theater. 3:08 Can you guess why? 3:10 Yep, that's right. 3:11 That's because the word set means something already in Java, right? 3:12 It's a unique list of items. 3:16 So, instead of a set it's called a scene graph. 3:18 Everything that you add to the scene graph is a called a node. 3:22 Node serves as the base class for all objects and it can be added to the scene. 3:26 Now much like java.lang.object is the base class of all objects, 3:31 the behavior inherited from node is as follows. 3:35 Nodes can have child nodes, meaning they contain other nodes. 3:39 And all except the first node will have a single parent property. 3:44 The first node added to the scene graph is known as the root node. 3:48 Let's take a quick look at the different types of nodes, and 3:53 what we can do with them, right after this quick break. 3:56
You need to sign up for Treehouse in order to download course files.Sign up