I keep getting some weird error in Processing, using the following tiny piece of code:
void setup() {
size(200,200);
}
void draw() {
background(0);
loadPixels();
updatePixels();
}
The error: (with stack trace)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:357)
at sun.lwawt.macosx.CImage$Creator.createFromImage(CImage.java:101)
at sun.lwawt.macosx.CPlatformWindow.getImageForTarget(CPlatformWindow.java:693)
at sun.lwawt.macosx.CPlatformWindow.updateIconImages(CPlatformWindow.java:519)
at sun.lwawt.macosx.CPlatformWindow.setVisible(CPlatformWindow.java:484)
at sun.lwawt.LWWindowPeer$1.run(LWWindowPeer.java:260)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:240)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:142)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:134)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Now at first I thought this was a bug, because there previously was another bug that disappeared when I restarted Processing. It seems it still doesn’t have good Mac OS X Lion support (that’s what I’m using). But I tried both the stable release and the prerelease and both have the same error. Has anyone else gotten this? Does anyone know how to fix it? Do I need to install a better JDK or something?
Oddly enough it started working fine after a couple of restarts. It’s weird and I don’t know why it behaved like that. Anyways, it works now.