How to use images and other content in RAWR
Images can be used on JButtons and JLabels pretty easily in Netbeans. Just click on the ellipsis (...) next to imageIcon, and find your image. However, this solution isn't very robust. Reading off te filesystem is great and simple, but that may not be an option for an all-jar deployment, such as when using Web Start, or even an updater like GetDown, which I believe only updates jars. Another problem with picking images straight off the filesystem is that I think Netbeans does some odd stuff with relative in absolute jars. In more recent versions, this seems to be getting better, but I still see some odd quirks from time to time. First off, you have to make some kind of media jar. Rawr handles this, and even includes a sample that's commented in your build_configuration.rb.
c.jars[:data] = { :directory => 'data/images', :location_in_jar => 'images', :exclude => /bak/}
I usually don't do the fancy :location_in_jar stuff myself (I think that's mostly there just to show you that you can do it).
c.jars[:data] = { :directory => 'data', :exclude => /bak/}
Much better. Now run your build task.
jrake rawr:jar
This will build your project, but it will also build a data.jar. You can find this jar inside package/jar. In Netbeans, add this jar to your project's classpath. For future images, simply drop more images into your data dir, and run your build task to refresh the jar. Now head back to your form with the image, and hit that ellipsis again. This time you want to pick Image Within Project.
Click on the ellipsis button to the right of the 'File:' (it has a blue boarder in the screenshot above). Then go find your media jar, and pick the file you're looking for.
That'll do the trick! For future images, just stick the jar in the data dir, re-run rawr:jar, and find the image in the jar through Netbeans. If you need to find images programatically, you'll need a classloader that's not JRuby's classloader (JRuby team, correct me if this has changed). In an all JRuby app, that might be hard to find. Fortunately, Rawr generates a method in the generated Main class that uses its classloader to help you get a resource.
Java::org::rubyforge::rawr::Main.get_resource('my-image.png')





