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 and 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...

  • 3
    $\begingroup$ It may be relevant that Swing is no longer undergoing active development, and JavaFX is considered to be its replacement. $\endgroup$
    – Ben I.
    Commented Jul 21, 2017 at 10:46
  • 1
    $\begingroup$ @BenI. I'll add: you are right. JX is literally meant to be a replacement. as per Oracle $\endgroup$
    – ItamarG3
    Commented Jul 21, 2017 at 12:22
  • $\begingroup$ what kind of school do you work in? is it a highschool? $\endgroup$
    – Harry
    Commented Jul 21, 2017 at 12:41
  • 1
    $\begingroup$ 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? $\endgroup$ Commented Jul 23, 2017 at 18:15
  • $\begingroup$ @CSCheerleader Good catch. I'll fix that now. Oversight on my part. $\endgroup$
    – Peter
    Commented Jul 23, 2017 at 20:58

3 Answers 3


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, 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:

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


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).

  • $\begingroup$ +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. $\endgroup$
    – TuringTux
    Commented Jul 23, 2017 at 14:36
  • $\begingroup$ @TuringTux that's a good point. $\endgroup$
    – ItamarG3
    Commented Jul 23, 2017 at 14:39

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, 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.


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. 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.

  • $\begingroup$ 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 :-/ $\endgroup$
    – Levon
    Commented Aug 8, 2017 at 16:23
  • $\begingroup$ 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. $\endgroup$
    – Levon
    Commented Aug 8, 2017 at 17:12
  • 1
    $\begingroup$ 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. $\endgroup$
    – iFrame
    Commented Aug 13, 2017 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.