Can't get setRGB to work

I get the following error at runtime:
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException
at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java)
at java.awt.image.BufferedImage.setRGB(BufferedImage.java)
at HorizonFinder.paint(HorizonFinder.java:44)
at java.awt.Container.update(Container.java)
at sun.awt.RepaintArea.update(RepaintArea.java)
at com.apple.mrj.internal.awt.VComponentPeer.reallyDoThePaintOrUpdate(VComponentPeer.java)
at com.apple.mrj.internal.awt.VComponentPeer.handlePaintEvent(VComponentPeer.java)
at com.apple.mrj.internal.awt.VComponentPeer.handleEvent(VComponentPeer.java)
at java.awt.Component.dispatchEventImpl(Component.java)
at java.awt.Container.dispatchEventImpl(Container.java)
at java.awt.Component.dispatchEvent(Component.java)
at java.awt.EventQueue.dispatchEvent(EventQueue.java)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java)
at java.awt.EventDispatchThread.run(EventDispatchThread.java)
The setRGB statement that its referring to is as follows:
for (int y=1; y<469; y++) {
if (y-horizon>1) {
rgb = play.getRGB(1, y);
play.setRGB(1, y-horizon, rgb);
play is a BufferedImage that works fine otherwise, and horizon is defined earlier. Any clues?
Matt

ok
for anyone else who is having a similar problem, I found a way around it. It's really clumsy, but, since the BufferedImage I was working with was going to a Graphics context anyway (using drawImage), I just got the color of each pixel I wanted (color=new Color(play.getRGB(x, y);) instead of just the getRGB method, and set the Graphics color to that (setColor(...))and used drawLine with the same start and end points. Whatever.
Matt

Similar Messages

Maybe you are looking for

  • I am currently running iOS 5 on my iphone 4S, is there any issue with the battery life if I update my phone software to iOS 6?

    I need help on this matter, this is the only thing that is keeping me from installing iOS 6. Also, how can I save my data, apps and other stuff that I already installed on iOS5? Also, if I create another apple ID, will my data, apps etc be lost, do I

  • Java plug in problem

    hello friends..... ...i m using html converter for java plug in ....and tried to convert a jsp page .but jsp still not showing the applet. and there is not any changed occured in jsp file. please tell me what may be the reason??

  • Small (visible) images on published Iweb page

    I generated a web page recently, loaded, looked at it under Safari, Explorer and Firefox. So far so good. When my friend looks at it on her Macbook pro 13" laptop, all the images in the slideshow are not much bigger than thumbnails - maybe 200 px max

  • Reg. No direct postings can be made to G/L acct. 221002 in CoCode NCCP

    Dear Experts I am getting the following error when I goods receipt against customer stock (501 mvt) " Acct. 221002 for trans./event key BSX, postable directly " After made tick in  " Post automatically only " the above problem solved. Next, when I cr

  • Email form with checkboxes

    Hi All, I have a form with checkboxes that I finally got to work partially. However, there is one problem. If you forget to check the checkbox, (Yes or No), you get the error Element is Undefined. If you check the checkbox there is no problem and the