Releasing ViralSpread: A Contagion Simulation Program

Thu, Nov 17, 2011 - 8:21pm -- Isaac Sukin

ViralSpread is a FOSS program that simulates a competitive contagion scenario. You can adjust the simulation's parameters and it will report various statistics about the simulation including graphs and exportable data. You can download the program (including the source code and screenshots) or check out the source code on github.

You can also read about the development process.

Java Validated FileChooser

Fri, Nov 4, 2011 - 7:55am -- Isaac Sukin

I happened to be working on a Java project recently where I needed to let the user save files through the GUI. The Swing toolkit has a nice JFileChooser class that lets you show a file save dialog so that the user can choose the directory and name of the file to save. However, not all filenames are valid, and Java doesn't validate them for you by default. If you try to save a file with an invalid name, Java will throw an error, and this is often considered the only way to know if the filename is valid. That's bad practice though since you should never rely on an exception being thrown as a condition of your program running correctly; by definition, exceptions are unreliable and sometimes unpredictable. Additionally if your file saves successfully then you have to immediately delete it (because you were only saving it to test the filename) and that's messy. So I wrote a ValidatedFileChooser class that checks various criteria to make sure that filenames are valid before attempting to save the file, and alerts the user if one of the criteria fails. The class is below, and I'm releasing it to the public domain.

Subscribe to RSS - java