Mega 2560 can't run "Dimmer" example

I just bought my Mega 2560 from Radio Shack yesterday and was going thru the examples today and stumbled upon the Dimmer sample. I downloaded Processing and played around with that for a bit and then went to run the Dimmer and came upon the same issue reported above. I did some Googling and it seems to have been a common problem for at least a couple of years and no one seemed to find an answer.

Well, after an hour or so trying various things, I stumbled upon the answer. XD I was messing around with the DOS MODE command and noticed the options for dtr=on|off|hs. That got me thinking that maybe the issue is something to do with the handshaking. So I looked thru the Processing folder and found Serial.java and inside it I noticed the function setDTR.

So I went back to the Dimmer code and added port.setDTR(true); but it didn't work. But then I remembered reading another post about adding a delay, so I added a 500ms delay before and after and voila! It worked!

The funny thing is if I lower either delay from before or after the setDTR it doesn't work, so it seems it needs to be at least 500ms. Here is my revised Dimmer code for Processing:
...
port = new Serial(this, "COM3", 9600);
delay(500);
port.setDTR(true);
delay(500);
}

void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
stroke(i);
line(i, 0, i, 150);
}

// write the current X-position of the mouse to the serial port as
// a single byte
port.write(mouseX);
}

I hope this helps.