NOTE:
THIS APPLICATION WILL ONLY WORK WITH SWING 1.1 Beta 3
(YOU CAN GET THIS FROM http://java.sun.com or http://www.PsychoticSoftware.com)


Inner Resources are a great new feature of Unity. However, they do require
some help on your part to be useful. A full tutoral will be added to
our website (http://www.PsychoticSoftware.com) shortly. For now, here is a
brief example.

In this example, lets say we have a resource that is a gif image, and it
is in a directory called gfx, relative to the location of the calling class
file. The resource file is icon.gif  ("gfx/icon.gif -- Note the FORWARD slash)

Traditionally, to use this resource, we would use the method 
****  URL resource = getClass().getResource("gfx/icon.gif");   ********
This returns a URL pointing to our resource. Unfortunately, the URL class
is declared to be final, so we couldn't extend it to use inner resources.

Hence, Inner resources use streams instead of URLs.
This is accomplished in a similar manner as above. The corresponding method is:
****  InputStream resource = getClass().getResourceAsStream("gfx/icon.gif");   ********
If the specified resource is included in the Unified class file, you will get a
direct stream from within this file, without having to extract the resource first.
If the resource is not found, the method will do what it usually does.

Now lets show how to Display an icon in a title bar using Inner resources.
-------------------------------------------------------------------------

The trick here is converting the input stream into the type of resource we need.
For small files, it is best to convert the stream into an array of bytes and work with the
array. Here is a method which can do that for you:

  public static byte[] getBytesForStream(InputStream ins)
  {
    try
    {
      java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
      byte[] data = new byte[1024];
      int length = 0;

      while((length = ins.read(data)) != -1)
      {
        baos.write(data, 0, length);
      }
      return baos.toByteArray();
    }
    catch(Exception x) {return new byte[0];}
  }


Now, to use the resource, use something like below:

class ResourceFrame extends Frame
{
  public ResourceFrame()
  {
    try
    {
      InputStream is = getClass().getResourceAsStream("gfx/float.gif");
      Image image = Toolkit.getDefaultToolkit().createImage(Tools.getBytesForStream(is));
      setIconImage(image);
    }
    catch(Exception e) {;}

    setSize(200, 200);
    setVisible(true);
  }
}

=========================

When Unifying, just include all required classes and put the resource in the "inner resources tab"

That's it!