Archive for the ‘SnapCode’ Category

SnapStudio – a physics drawing app

April 12, 2018

Here’s a fun new app in the browser written in Java with Box2D. I basically took a version of ReportMill and added Box2D support, turning every vector shape you draw into a Box2D shape, so that when you hit the “Preview” button, all the shapes fall with gravity and interact with each other. You can even click and drag a shape to further knock things around.

It’s not particularly useful at the moment – but it’s definitely kind of fun.


Click the image to run in the browser. Send me a note if you think it’s cool (jeff at reportmill).


SnapKit Builder updates

April 5, 2018

I added some new features to SnapKit UI Builder this week:

  • Added support for the Margin attribute to make it easy to define space around a view
  • Added arrow controls to Margin and Padding to make it easy to modify these values
  • Added a new ArrowView control to easily add up/down and left/right to any UI
  • Added JavaDoc button to quickly take you to the JavaDoc for any UI element
  • Added text to show the current bounds of the selected view

SnapKit UI Builder in Browser

Click image to visit the launch page.

SnapKit Builder with improved XML

March 9, 2018

This week I added improvements for the XML viewer in SnapKit UI Builder:

  • Synchronize Editor view selection with XML text selection
  • XML syntax coloring

New XML features

Click image to visit the launch page.

WebCode – a Java IDE in the browser

May 20, 2017

I’m jumping the gun on this demo, but it’s interesting enough that I have to share it in it’s current state.

My goal with WebCode is to provide an in-browser IDE, like I’ve seen for other tools and languages (like TypeScript and Kotlin). The idea is to show a number of working examples that can be run directly, or modified/compiled on the server with javac and TeaVM and the result is returned to the browser and launched in a separate window.

Launch WebCode in Browser

This preview version has the basic SnapCode project file manager and shows a few sample source files from our SnapCode/TeaVM demo page. The source files have Java syntax coloring and can be edited. When you hit the run button, it launches one of our existing TeaVM samples.
I only have a few days of work in this so far (using SnapKit and skeleton files from SnapCode). The current version is client side only, so it doesn’t compile anything. My next step is to add the server component so the client can post modified source, do the compile and return a link to a launch html.
Let me know what you think!

Secretly teach advanced programming to beginners

April 21, 2017

A few years ago I taught an after school coding class to middle schoolers and used a common strategy: I started with two weeks of the Scratch programming tool to teach fundamentals with simple drag and drop instructions, then migrated to a specialized IDE, Greenfoot, to teach basic Java in the context of graphics apps, then moved to a catch-all IDE for more general programming.

The downside was a sizable stumble each time we switched tools – two steps forward, one step back. Since then I’ve been hoping for a solution to avoid this. A solution to teach each new concept in a way that prepares students for the next concept, instead of covering it up.

The current iteration of SnapCode embodies this. With a five minute lesson, I can cover the following:

  • Create a controller class that uses the Model-View-Controller paradigm
  • Snap together blocks of instructions to build real lines of Java code
  • Build a scene for the application using a real UI builder
  • Run on the desktop and in the browser using Java and Java-to-JavaScript transcompiler

Check out the video to see it in action.


If you like this, please like/retweet the blog, video, tweet (tweet is here).

Java CLI in the Browser not as Stupid as it Sounds

October 27, 2016

Stay with me here, this may sound silly unless you are a teacher or student, but a standard part of many intro programming classes is learning the traditional Command Line Interface with simple tools like System.out.println() and java.util.Scanner. This lets you learn the basics of input, output and data processing with only a few lines of code:

System.out.println("Enter two numbers:");
Scanner scan = new Scanner(;
int val1 = scan.nextInt();
int val2 = scan.nextInt();
System.out.println("Total value is: " + (val1 + val2));

With just these basics you can write many interesting programs:

  • Calculators, formula solvers, quizzes, surveys
  • String manipulation: word counting, palindromes, anagrams, etc.
  • Text based adventure games, digital psychologist, etc.

This was the only way to learn when I started on the TRS-80 and Apple II, and it’s still a great way to learn today, without introducing too many concepts that overwhelm new students. The downside is that these programs tend to be locked in the IDE or a terminal.

However, using a class called SnapPane, via one extra line of code, the same app that runs at the console pops up a window instead and runs on the desktop. And with SnapTea, and another line of code, you can then run in the browser and share with the world. Here’s a command line calculator running in the browser (notice, also, a tab to view the source code):

Simple Calculator using println and Scanner

SnapCode is a free IDE for education. Please like the blog, video, tweet (and retweet!) and join the discussion group if you’d like to hear more.


(video demo)

Java UI Builder for the Browser and Desktop

October 13, 2016

Last week I showed an example of writing just a few lines of UI code and running it on the desktop and in the browser, using SnapCode, SnapKit and TeaVM.

Well that was downright barbaric. There is a better way to design UI than code, compile and iterate: it’s a UI builder. This week I get rid of those extra lines of code by generating the UI in SnapCode’s UI builder. Much more civilized – and perhaps the most high-level “Hello World” ever seen.

This is the system I wish Flash had been: Visual designer, code editing, project file management, native browser (no plugin), native desktop and support for the most popular programming language on the planet.

SnapCode is a free IDE for education. I’d love to hear feedback. Please like the blog, video, tweet (and retweet!) if you’d like to see more.


Quickest way to Java in the Browser

October 4, 2016

This week SnapCode was updated to automatically convert SnapKit Java apps to JavaScript and launch in the browser when it detects an app is linked against TeaVM (an incredible Java-to-JavaScript transpiler). This finally makes it trivial to write a Java UI app and immediately run in the browser.

I’m not a fan of demos with coding, but this is a UI version of “Hello World” (it’s only a few lines of code). The UI builder version of this demo will be available in a few weeks.

As a Java developer, I’m very excited. I have jumped through many hoops over the years with Applets, Web Start and native app packaging, and still I don’t have the ability to share and distribute even basic apps without a disproportionate amount of work. Until now.

SnapCode is a free IDE for education. I hope people check it out.


If you want more – please like/retweet the blog, video, tweet. (tweet is here)!

Rich Java in the Browser with SnapKit and TeaVM

September 20, 2016

I’ve been playing around more with my SnapTea project. SnapKit is my Java client library for writing rich apps on top of either Swing or JavaFX. TeaVM is a remarkable bytecode to JavaScript transpiler. SnapTea is SnapKit with a TeaVM adapter – so I can compile and run my SnapKit Java desktop apps in the browser.

With SnapKit, I can easily write a rich Java desktop app in the conventional fashion. I build UIs as a hierarchy of Views containing text, images, graphics, buttons, sliders and more Views. Once I’m done, I run TeaVM from the command line and it generates a compact Classes.js file that opens in my browser.

So my project this week was to write a simple showcase application: BusyBox. This app contains many of the controls found in SnapKit. This is just a first version, with just a few hours of development, so check back later for updates!


Java Desktop apps to JavaScript

July 13, 2016

My ideal dev platform would be a Java environment that lets me write fully functional, rich native desktop apps that I can also build/run natively for the browser, even if in limited fashion (but without plugin).

So two years ago I started writing my own UI kit, Snapkit, that has the modern features of JavaFX, but adheres more to Java conventions like Swing. My big cheat (and epiphany) was to implement the bottom most system interaction (graphics, input events, clipboard) as an adapter. So Snapkit can easily run on top of either Swing or JavaFX, in any Swing Component or JavaFX Node. It really only relies on a Painter, supplied through the adapter (Graphics2D or JFX Canvas). All of the graphics primitives (Shape, Rect, Path, Color, Font, Transform, etc.) and all of the components (Button, Slider, TextField, List/Table/TreeView, etc.) are implemented in Snapkit.

So since this adapter model eliminates most system dependent code, I was able to reasonably embark on an adapter to run a Snapkit desktop app in the browser. This is when I found TeaVM – a remarkable system that compiles Java bytecode to JavaScript that supports a good subset of the standard Java class library. It compiles only referenced code, so the resulting JavaScript is amazingly small.

So far my two test cases are a (1) SimpleTest that has button, slider, label, images, vector graphics, text and animation and (2) Greenfoot Asteroids, an asteroids implementation written in Greenfoot (with a simple glue library I wrote to emulate Greenfoot in Snapkit).

The interesting thing about these two apps is that I can change one line of code to run them as native desktop applications, with access to full desktop features and performance (and a 40mb download). Or I can deploy in a much more accessible fashion to the browser, where there is no download step to scare potential users away (but with some missing features). Eventually, I could add a third option where the app runs client/server: still no download, and more functionality, but slower runtime performance (due to networked graphics). Those are options I can live with!

I still need time to properly integrate this into SnapCode, and SnapCode itself still needs some work. But here are the two apps:


I’d love to hear any feedback people have. I’ve been aching for a solution along these lines for years – I wish Oracle would do this with JavaFX and/or Swing. With WebAssembly I hope we’ll see more of this. Feel free to comment or send me a note at jeff at reportmill.