I’m preparing for my presentation on Processing this Sunday at Flash Festival 2007. For this conference I’ve adapted a very sturdy presentation system I started in Lingo way back in 2000. The conversion has been relatively painless, except for the occasional details.

Thanks to Marius Watz and VitaFlo I’ve been able to make a nice Mac OS X full screen application that can open other windows on top of it. Usually Processing runs full-screen applications Java-style, i.e. on top of all other windows, including the dock & menu. But since I want my Applet to be a launching-pad for several websites, videos, and applications, I needed a different solution. Marius’ proposition only removes the menu & dock; this allows for many different solutions for what I want, several of which I’m exploring this week.

But one thing that was bothering me was the operating system’s imposed drop shadows. Mac OS X adds these love-em-or-hate-em shadows for a pseudo(d*3) look, but because of my design choices I wanted them gone. I first tried Window Shade X, but that was lame because it’s a system-wide hack. When you think about it, it’s just a simple application parameter; for example, applications built directly in Apple’s Cocoa environment have drop-shadows as an option that you can just check off from within Interface Builder:

Drop Shadow checkbox in Interface Builder

So after a quick search in Apple Developer Forums on removing drop shadows in Java, I found the following code that is fairly easy to adapt to any Processing Applet :

import com.apple.cocoa.application.NSApplication;
import com.apple.cocoa.application.NSWindow;
import com.apple.cocoa.foundation.NSArray;


public void setShadow(String windowTitle, boolean isShady)
{
  final NSApplication application = NSApplication.sharedApplication();
  final NSArray windows = application.windows();
  Enumeration e = windows.objectEnumerator();
  boolean done = false;
  while (!done && e.hasMoreElements()) {
    NSWindow w = (NSWindow)e.nextElement();
    if (w != null && windowTitle.equals(w.title())) {
      w.setHasShadow(isShady);
      w.invalidateShadow();
      done = true;
    }
  }
}

You just have to include this code into your applet, and then call:

void setup() {

  size(500,500);
  setShadow("", false);

}

There should also be a way to remove shadows via the info.plist, but I wasn’t able to get the right combination.

If you analyze the above code, basically what you have is a hook to the Cocoa platform that looks through all the windows for the one that contains your Java applet. Once you’ve found it, you can easily deactivate its shadows.