One of the things that always comes up in example code; is the requirement to "show" the result. As a result a the majority of our example code was actually examples of how create quick and dirty swing user interfaces.
So our day was spent stripping out boilerplate user interface code to a jar appropriately tilted "gt-swing" so that examples can stay focused on being examples.
Here is a small example of a wizard page for connecting to a shape file:
Here is before:
File file;
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Open Shapefile for Reprojection");
chooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.isDirectory() || f.getPath().endsWith("shp")
|| f.getPath().endsWith("SHP");
}
public String getDescription() {
return "Shapefiles";
}
});
int returnVal = chooser.showOpenDialog(null);
if (returnVal != JFileChooser.APPROVE_OPTION) {
System.exit(0);
}
file = chooser.getSelectedFile();
And here is after:
File file = JFileDataStoreChooser.showOpenFile("shp", parent );
Documentation harmed in the making of todays blog: