Skip to content
Snippets Groups Projects
Commit 3c4acc81 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Updated README to improve suitability for CSCE 361 "setup" assignment.

- Removed IDE installation instructions
- Removed editorial comments about IntelliJ IDEA vs Eclipse
- Instruct students to obtain Scene Builder for Java 8 to guarantee
  compatiability with settings in the pom.xml files in the starter code.
parent 3e7cc7b4
Branches
No related tags found
No related merge requests found
<!--
# Installing IntelliJ IDEA (macOS/Windows)
While you are not forced to use IntelliJ over Eclipse or any other IDE, it is recommended over Eclipse.
While you are not forced to use IntelliJ over Eclipse or any other IDE, it is recommended over Eclipse.
1. Navigate to the [official site](https://www.jetbrains.com/idea/download/#section=windows) for IntelliJ IDEA.
2. Download the **free** community edition.
3. Wait about 5 seconds the download to start, and then run the executable after it is finished downloading. (For Mac, it will be a `.dmg` file, and for Windows, a `.exe` file.
......@@ -22,11 +23,20 @@ While you are not forced to use IntelliJ over Eclipse or any other IDE, it is re
6. Install the Eclipse IDE For Java Developers, the top option.
7. Accept the licenses, the installation will take a while.
8. When the installation is complete, launch Eclipse.
-->
# Installing JavaFX Scene Builder (macOS/Windows)
# Installing JavaFX Scene Builder
1. Navigate to the [official site](https://gluonhq.com/products/scene-builder/#download) for the JavaFX Scene Builder.
2. In the middle of the page, click the download button for your respective operating system.
<!-- 2. In the middle of the page, click the download button for your respective operating system. -->
2. At the bottom of the of the page, under "Download Scene Builder for Java 8,"
click the download button for your respective operating system. *Do **not**
download Scene Builder for Java 11*. The project starter code we provide
instructs your IDE to build applications to the Java 8 stable release; we
don't know if the `.fxml` files generated by Scene Builder for Java 11 will
function correctly with Java 8 code.
- If you have already installed Scene Builder for Java 11, we welcome
your experience report.
3. This will take you to a page labeled 'Thanks.' Your download will begin in about 5-10 seconds automatically; you can ignore each of the green buttons on the page.
- If you are installing on macOS, this will download a `.pkg` file - and then you can just walk through the installation upon clicking on the `.pkg` file.
- Otherwise, if you are on Windows, walk through the executable installer.
......@@ -34,12 +44,10 @@ While you are not forced to use IntelliJ over Eclipse or any other IDE, it is re
# Using the JavaFX Scene Builder
This tutorial will walk you through creating a basic JavaFX application. The end-product of this tutorial, along with other example works, can be found within `CSCE 361` -> `examples` -> `JavaFX SceneBuilder Examples`.
This tutorial will walk you through creating a basic JavaFX application. The end-product of this tutorial, along with other example works, can be found [on gitlab](https://git.unl.edu/csce_361/examples/javafx-scenebuilder-examples).
## Using SceneBuilder with IntelliJ IDEA
Your life will be infinitely easier if you just use IntelliJ IDEA in conjunction with JavaFX Scene Builder.
1. Open IntelliJ.
2. Click `Create New Project`.
3. Create a new JavaFX application.
......@@ -47,18 +55,18 @@ Your life will be infinitely easier if you just use IntelliJ IDEA in conjunction
5. Click `Settings`, and then `Languages and Frameworks`.
- If you are running IntelliJ IDEA on a Mac, you instead go to `IntelliJ IDEA -> Preferences -> Languages and Frameworks`.
6. Click on `JavaFX`.
7. Set the path to where your `SceneBuilder.exe` (on Windows) or `SceneBuilder.app` (on macOS) is installed at.
7. Set the path to where your `SceneBuilder.exe` (on Windows) or `SceneBuilder.app` (on macOS) is installed at.
8. Click `OK`.
9. IntelliJ should have generated three files within the `src` directory of your project, within a package called `sample`.
10. Rename this `sample` package to `app`.
- Make sure all occurrences are renamed to `app`.
11. Find the file entitled `sample.fxml`, and rename it to `home.fxml`.
12. Right click on the file, and click the option that says `Open In SceneBuilder`.
12. Right click on the file, and click the option that says `Open In SceneBuilder`.
- This is the file that holds all of the code for the look of your application. Now that you've opened it up directly, whenever you make changes within the SceneBuilders, those changes will also be reflected with `home.fxml` whenever you click save.
## Using JavaFX Scene Builder with Eclipse
Eclipse does not natively support the JavaFX Scene Builder in the way that IntelliJ IDEA does. To get around this, you are going to have to manually install the JavaFX plugin for Eclipse - which is why it is recommended you just use IntelliJ IDEA instead. Even when the plugin is installed, life is made more difficult as `.fxml` projects are not automatically generated in conjunction with new JavaFX projects. In conclusion: make your life easier and just use IntelliJ IDEA.
Eclipse does not natively support the JavaFX Scene Builder "out of the box" like IntelliJ IDEA does. To get around this, you are going to have to manually install the JavaFX plugin for Eclipse.
1. Open Eclipse.
2. Go to `Help` in the navigation bar.
......@@ -67,8 +75,8 @@ Eclipse does not natively support the JavaFX Scene Builder in the way that Intel
5. Click `Add...`, and give it the following name: `e(fx)clipse`.
6. Click OK, and and now select both of the shown checkboxes.
7. Click `Next >`, and wait for e(fx)clipse to finish installing.
8. Click `Finish`.
9. When the installation is finished, Eclipse will prompt you for a restart. Do that.
8. Click `Finish`.
9. When the installation is finished, Eclipse will prompt you for a restart. Do that.
10. Now, you will be able to create new JavaFX project from the 'New Project' wizard of Eclipse. Create a new JavaFX project.
11. Within the `src` directory of your new project, a package called `application` will have been generated. `Main.java` is the driver code. Create a new file called `home.fxml` within this package.
12. Right-click your newly created file and click `Open with SceneBuilder`.
......@@ -77,6 +85,12 @@ Eclipse does not natively support the JavaFX Scene Builder in the way that Intel
- Go to JavaFX, and then set the SceneBuilder executable to wherever your `SceneBuilder.exe` is saved at. Apply and Close.
- Now, you should be able to open SceneBuilder from Eclipse!
## Using JavaFX Scene Builder with other IDEs (or without an IDE)
JavaFX Scene Builder will function as a standalone application. You can use the
standalone application to prepare the `.fxml` files and your IDE (or a non-
integrated editor) to prepare the `.java` files.
## Building your first application
1. Now that the SceneBuilder is open, we can talk about the different components of it:
......@@ -112,7 +126,7 @@ Now that we have three buttons for input and a label with starter text in it, le
2
3 import javafx.fxml.FXML;
4 import javafx.scene.control.Label;
5
5
6 public class HomeController {
7 @FXML private Label middle;
8
......@@ -131,12 +145,12 @@ On line 7 we are declaring a `Label` object entitled `middle`, and it is annotat
6. Now that you have the stub code pasted in, navigate back to the SceneBuilder.
7. Click on the left button, and go to the `Code` panel in the `Inspector`.
8. In the `Main` subgroup, under `On Action`, type in the name of the function you wish to be called when the button is clicked - in this case, it's just `clickLeftButton`.
8. In the `Main` subgroup, under `On Action`, type in the name of the function you wish to be called when the button is clicked - in this case, it's just `clickLeftButton`.
9. Do the same for the other two buttons and their respective functions.
10. In order to actually test out your new program, you are going to have to link the GUI to the controller - so on the bottom-left portion of your page, open up the `Controller` panel.
11. In `Controller Class`, type in `app.HomeController` - that's the package name followed by the name of the Controller class.
12. Now that everything is linked together, you can run the program out of `Main` and see that the label text changes on each button press, exactly as intended.
- You may want to change the resolution of the scene within `Main`, as it is probably a bit too small currently.
- You may want to change the resolution of the scene within `Main`, as it is probably a bit too small currently.
### Switching Between Screens (Scenes)
......@@ -157,10 +171,10 @@ public void switchScreen(javafx.event.ActionEvent event) throws IOException {
FXMLloader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("secondScreen.fxml"));
Parent parent = loader.load();
Scene scene = new Scene(parent);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}
......@@ -175,7 +189,7 @@ public void switchScreen(javafx.event.ActionEvent event) throws IOException {
8. Run the application and verify that you can switch screens by pressing the button.
9. Now, copy and paste the same function into the new `SecondScreenController`, changing out `secondScreen.fxml` for `home.fxml`.
10. Link `secondScreen.fxml` to the `SecondScreenController` as we did previously in Step 11 of "Registering Event Handlers."
11. You should be able to move back and forth between the two scenes now!
11. You should be able to move back and forth between the two scenes now!
### Passing Data Between Scenes
......@@ -190,4 +204,4 @@ As of right now, our application doesn't have any data confined to it, nor does
7. Open up `secondScreen.fxml`.
8. Remove the `Label` from the `AnchorPane on top`, and add 4 new `Label`s:
- First `Label` should say 'Selected Items:'
- The next three labels should all be blank.
\ No newline at end of file
- The next three labels should all be blank.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment