<p>Disclaimer: some <em>do</em> consider this a war like emacs/vim. I don't.</p>
<p>I'll quote you on this: &quot;I'm looking for something that allows students to get up and running relatively quickly and easily with something small yet meaningful&quot;.</p>
<p>From this: JavaFX. Along with IntelliJ, and <a href="http://www.oracle.com/technetwork/java/javase/downloads/javafxscenebuilder-info-2157684.html" rel="nofollow noreferrer">Scene Builder</a>, students can build a GUI very, very quickly. The FXML file which &quot;creates&quot; the GUI also gives an introduction to XML file structure.</p>
<p>It also teaches many Java 8 things. This is vague, but here are some examples:</p>
<ol>
<li>A lot of lambda expressions.</li>
<li>Work with <code>Collection</code>. The students would need to use the collections in java 8, if they learn JavaFX. This is handy, because those classes are obviously useful outside of AP CS A</li>
<li>The Stream API (which gets buffed in Java 9, coming out soon) has a lot of usage as well in JavaFX.</li>
</ol>
<p>I could continue this rant forever, but the main point is that JavaFX is self-dependent, which means that it only requires itself and java, unlike Swing, which requires AWT.</p>
<p>I hope this give you some idea about putting a GUI library in your curriculum.</p>
<hr />
<p>As was pointed out in a comment, JavaFX has an added bonus: It's more likely to become the library your students would use, if their careers lead them to doing GUI in Java. I say this because <a href="http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6" rel="nofollow noreferrer">Oracle said so</a>:</p>
<blockquote>
<h3>6. Is JavaFX replacing Swing as the new client UI library for Java SE?</h3>
<p>Yes.</p>
</blockquote>
<p>The link contains more details, but the core of that part of the faq is that it <strong>is</strong> a replacement. (Which is in no way saying that Swing will not be included in future Java releases, because of backwards compatibility).</p>

CC BY-SA 3.0
2017-07-23T14:36:38.703Z
+1 Also, if you teach your students JavaFX instead of Swing, they've already made experiences with the framework which will probably be used in the future.
TuringTux
CC BY-SA 3.0
2017-07-23T14:39:23.940Z
@TuringTux that's a good point.
ItamarG3
CC BY-SA 3.0
2017-07-21T06:37:22.220Z
2017-07-23T14:46:33.597Z
2020-06-18T08:36:57.023Z
ItamarG3
<p>I'm going to suggest that you don't use either Swing or JavaFX for an AP CS course. Instead, I'm going to suggest that you use <a href="http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html" rel="nofollow noreferrer">Princeton's Standard Draw library</a>. It does a great job of abstracting all of the ugly canvas and window setup that traditionally comes along with Swing or JavaFX. </p>

<p>I have leveraged their library for multiple projects throughout the year and my students never complained about not understanding the graphics side of the projects. Full disclosure: StdDraw isn't as powerful as Swing of JavaFX, but why bring a nail gun to a job when a simple little hammer will do the trick? </p>

<p>We use StdDraw within the first couple of weeks in the course and it simplifies the process for both teacher and student, while still allowing you to focus on the important learning outcomes. Plus their API is easy to read and serves as a great introduction to students about how to read documentation. </p>

<p><strong>tl;dr:</strong> The easiest library to add graphics to your project and for your students' use is <a href="http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html" rel="nofollow noreferrer">Princeton's Standard Draw library</a>. </p>

CC BY-SA 3.0
2017-08-08T16:23:51.570Z
This sounds promising, I'll have to check it out, I'm looking for something super-simple just to engage students. Preferably something that can be used without having to have administrative rights to install since our IT department is very (very) restrictive in what we can do :-/
Levon
CC BY-SA 3.0
2017-08-08T17:12:53.363Z
Does this package also support basic GUI functionality such as text boxes, buttons, etc - my initial scan shows only graphical functionality for drawing etc. Thanks. I would like to be able to have some non-console IO for my students to use.
Levon
CC BY-SA 3.0
2017-08-13T19:05:22.827Z
It doesn't support buttons and text fields like you see with JavaFX or Swing. However, it does support interactivity with the keyboard and mouse so you can get creative with students providing input. Although it isn't a extensive as Swing or JavaFX, the tradeoff is that you get a lightweight and easy-to-use framework for integrating graphics and user input. I'd be more than happy to chat offline about how I used this for my AP CS kids and to bounce around ideas for accomplishing what you want.
iFrame
CC BY-SA 3.0
2017-07-23T14:17:27.277Z
2017-07-23T14:23:17.443Z
2017-07-23T14:23:17.443Z
iFrame
<p>Like everything else in programming, it's a mix of tradeoffs:</p>

<ul>
<li><strong>Benefits of Swing:</strong> There are a metric ton of tutorials and examples on the web. It still has a very active community here on Stack Overflow.</li>
<li><strong>Downsides of Swing:</strong> It's old, and it looks old. It's not being actively developed anymore. (But it's not deprecated either.)</li>
<li><strong>Benefits of JavaFX:</strong> It's new(er), and it's being actively developed.</li>
<li><strong>Downsides of JavaFX:</strong> There are fewer tutorials and examples on the web, and many of them are outdated because JavaFX is under active development. I also find it more complicated than Swing, but maybe that's just me.</li>
</ul>

<blockquote>
  <p>Which framework is more appropriate for students learning Java as a part of the AP CS A curriculum?</p>
</blockquote>

<p>I don't think either one is very obviously better or worse than the other. They're very similar in a lot of ways, especially if you haven't used either one at all yet. Honestly the best thing you can do is try out a few hello world programs in both and see which one you like better.</p>

<p>I will also say that neither one of these is used extensively in the real world. Everything is either a web app or a mobile app. I can only think of a couple of Java-based desktop applications.</p>

<p>I'll also add a shout-out to <a href="https://processing.org/" rel="nofollow noreferrer">Processing</a>, which is a Java-based language (which can be used as a Java library) that makes it easy to create visual, animated programs without all of the boilerplate that Swing or JavaFX require. Might not be right for your class, but definitely worth checking out.</p>

CC BY-SA 3.0
2017-07-21T17:28:59.307Z
2017-07-21T17:28:59.307Z
Kevin Workman
<p>I attended an AP workshop this week to prepare for teaching AP CS A this coming school year. It gave me my first glimpse of Swing, which has now piqued my interest about including some GUI components in my course (something I had heretofore not anticipated). There are a couple other excellent questions/comments here about frameworks for GUIs in Java: <a href="https://cseducators.stackexchange.com/questions/638/introducing-the-mvc-pattern-along-with-javafx">Introducing the MVC pattern along with JavaFX</a> and <a href="https://cseducators.stackexchange.com/questions/2757/lesson-plan-for-teaching-java-graphics">Lesson plan for teaching java graphics</a>. All this got me thinking...</p>

<p><strong>Which framework is more appropriate for students learning Java as a part of the AP CS A curriculum?</strong></p>

<p>I'm looking for something that allows students to get up and running relatively quickly and easily with something small yet meaningful. It won't be able to become a huge component of the class, so I'm hoping one or the other is more suited for somewhat fast learning appropriate for high school AP students.</p>

<p>Note: I hope I'm not unknowingly wading into a religious war akin to emacs/vim or tabs/spaces...</p>

CC BY-SA 3.0
2017-07-21T10:46:57.883Z
It may be relevant that Swing is [no longer undergoing active development](http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6), and JavaFX is considered to be its replacement.
Ben I.
CC BY-SA 3.0
2017-07-21T12:22:40.663Z
@BenI. I'll add: you are right. JX is literally meant to be a replacement. [as per Oracle](http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6)
ItamarG3
CC BY-SA 3.0
2017-07-21T12:41:12.277Z
what kind of school do you work in? is it a highschool?
Harry
CC BY-SA 3.0
2017-07-23T18:15:03.193Z
I noticed this is the first question with an ap-cs-a tag.  Perhaps you could re-tag your question with the more used ap-computer-science-a tag?
CS Cheerleader
CC BY-SA 3.0
2017-07-23T20:58:03.777Z
@CSCheerleader Good catch. I'll fix that now. Oversight on my part.
Peter
<java><ap-computer-science-a><resource-information><swing><javafx>
Framework choice for AP CS A students: Swing or JavaFX?
# Framework choice for AP CS A students: Swing or JavaFX?

(Asked by: username_0 on 2017-07-21)

I attended an AP workshop this week to prepare for teaching AP CS A this coming school year. It gave me my first glimpse of Swing, which has now piqued my interest about including some GUI components in my course (something I had heretofore not anticipated). There are a couple other excellent questions/comments here about frameworks for GUIs in Java: [Introducing the MVC pattern along with JavaFX](https://cseducators.stackexchange.com/questions/638/introducing-the-mvc-pattern-along-with-javafx) and [Lesson plan for teaching java graphics](https://cseducators.stackexchange.com/questions/2757/lesson-plan-for-teaching-java-graphics). All this got me thinking...

**Which framework is more appropriate for students learning Java as a part of the AP CS A curriculum?**

I'm looking for something that allows students to get up and running relatively quickly and easily with something small yet meaningful. It won't be able to become a huge component of the class, so I'm hoping one or the other is more suited for somewhat fast learning appropriate for high school AP students.

Note: I hope I'm not unknowingly wading into a religious war akin to emacs/vim or tabs/spaces...

**Tags:** java, ap-computer-science-a, resource-information, swing, javafx

> **Comments:**
> **username_1**: It may be relevant that Swing is [no longer undergoing active development](http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6), and JavaFX is considered to be its replacement.  
> **username_2**: @BenI. I'll add: you are right. JX is literally meant to be a replacement. [as per Oracle](http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6)  
> **username_3**: what kind of school do you work in? is it a highschool?  
> **username_4**: I noticed this is the first question with an ap-cs-a tag.  Perhaps you could re-tag your question with the more used ap-computer-science-a tag?  
> **username_0**: @CSCheerleader Good catch. I'll fix that now. Oversight on my part.  

---

## 3 answers

### Answer by username_2 on 2017-07-21. Score: 5

Disclaimer: some *do* consider this a war like emacs/vim. I don't.

I'll quote you on this: "I'm looking for something that allows students to get up and running relatively quickly and easily with something small yet meaningful".

From this: JavaFX. Along with IntelliJ, and [Scene Builder](http://www.oracle.com/technetwork/java/javase/downloads/javafxscenebuilder-info-2157684.html), students can build a GUI very, very quickly. The FXML file which "creates" the GUI also gives an introduction to XML file structure.

It also teaches many Java 8 things. This is vague, but here are some examples:

1. A lot of lambda expressions.
2. Work with `Collection`. The students would need to use the collections in java 8, if they learn JavaFX. This is handy, because those classes are obviously useful outside of AP CS A
3. The Stream API (which gets buffed in Java 9, coming out soon) has a lot of usage as well in JavaFX.

I could continue this rant forever, but the main point is that JavaFX is self-dependent, which means that it only requires itself and java, unlike Swing, which requires AWT.

I hope this give you some idea about putting a GUI library in your curriculum.

---

As was pointed out in a comment, JavaFX has an added bonus: It's more likely to become the library your students would use, if their careers lead them to doing GUI in Java. I say this because [Oracle said so](http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6):

> ### 6. Is JavaFX replacing Swing as the new client UI library for Java SE?
>
> Yes.

The link contains more details, but the core of that part of the faq is that it **is** a replacement. (Which is in no way saying that Swing will not be included in future Java releases, because of backwards compatibility).

> **Comments:**
> **username_5**: +1 Also, if you teach your students JavaFX instead of Swing, they've already made experiences with the framework which will probably be used in the future.  
> **username_2**: @username_5 that's a good point.  

---

### Answer by username_6 on 2017-07-23. Score: 2

I'm going to suggest that you don't use either Swing or JavaFX for an AP CS course. Instead, I'm going to suggest that you use [Princeton's Standard Draw library](http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html). It does a great job of abstracting all of the ugly canvas and window setup that traditionally comes along with Swing or JavaFX.

I have leveraged their library for multiple projects throughout the year and my students never complained about not understanding the graphics side of the projects. Full disclosure: StdDraw isn't as powerful as Swing of JavaFX, but why bring a nail gun to a job when a simple little hammer will do the trick?

We use StdDraw within the first couple of weeks in the course and it simplifies the process for both teacher and student, while still allowing you to focus on the important learning outcomes. Plus their API is easy to read and serves as a great introduction to students about how to read documentation.

**tl;dr:** The easiest library to add graphics to your project and for your students' use is [Princeton's Standard Draw library](http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html).

> **Comments:**
> **username_7**: This sounds promising, I'll have to check it out, I'm looking for something super-simple just to engage students. Preferably something that can be used without having to have administrative rights to install since our IT department is very (very) restrictive in what we can do :-/  
> **username_7**: Does this package also support basic GUI functionality such as text boxes, buttons, etc - my initial scan shows only graphical functionality for drawing etc. Thanks. I would like to be able to have some non-console IO for my students to use.  
> **username_6**: It doesn't support buttons and text fields like you see with JavaFX or Swing. However, it does support interactivity with the keyboard and mouse so you can get creative with students providing input. Although it isn't a extensive as Swing or JavaFX, the tradeoff is that you get a lightweight and easy-to-use framework for integrating graphics and user input. I'd be more than happy to chat offline about how I used this for my AP CS kids and to bounce around ideas for accomplishing what you want.  

---

### Answer by username_8 on 2017-07-21. Score: 2

Like everything else in programming, it's a mix of tradeoffs:

* **Benefits of Swing:** There are a metric ton of tutorials and examples on the web. It still has a very active community here on Stack Overflow.
* **Downsides of Swing:** It's old, and it looks old. It's not being actively developed anymore. (But it's not deprecated either.)
* **Benefits of JavaFX:** It's new(er), and it's being actively developed.
* **Downsides of JavaFX:** There are fewer tutorials and examples on the web, and many of them are outdated because JavaFX is under active development. I also find it more complicated than Swing, but maybe that's just me.

> Which framework is more appropriate for students learning Java as a part of the AP CS A curriculum?

I don't think either one is very obviously better or worse than the other. They're very similar in a lot of ways, especially if you haven't used either one at all yet. Honestly the best thing you can do is try out a few hello world programs in both and see which one you like better.

I will also say that neither one of these is used extensively in the real world. Everything is either a web app or a mobile app. I can only think of a couple of Java-based desktop applications.

I'll also add a shout-out to [Processing](https://processing.org/), which is a Java-based language (which can be used as a Java library) that makes it easy to create visual, animated programs without all of the boilerplate that Swing or JavaFX require. Might not be right for your class, but definitely worth checking out.


---

